Is there a Namespace Reference somewhere?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jm

    Is there a Namespace Reference somewhere?

    For example, I cannot get this to work (in my page_load on the
    server):

    chkCompleted.at tributes.add("o nclick", "javascript:ret urn confirm('Are
    you sure?');")

    My code is:

    <asp:datagrid.. ..>
    <columns>
    some boundcolumns
    <asp:Template ColumnHeaderTex t="Completed"
    ItemStyle-HorizontalAlign ="Center">
    <ItemTemplate >
    <asp:checkbox id="chkComplete d" Runat="server" />
    </ItemTemplate>
    </asp:TemplateCol umn>
    </columns>
    </asp:datagrid>

    I get an error that chkCompleted is not declared. My guess is that I
    have not imported the correct namespace. I have tried several, just
    guessing but I haven't found the right one.

    Where is a good reference for this? Thank you and links are
    appreciated.
  • Kosic

    #2
    Re: Is there a Namespace Reference somewhere?

    Hi,

    In fact , the WebControls in DataGrid Template Column appear another control
    ID in client html.For example, if you put a "LinkButton 1" in the Template
    Column, in client side, the ID is auto changed to
    "DataGrid1__ctl ?_LinkButton1", so that you can't add attributes on ID
    "LinkButton 1" correctly.

    Try to do this: during the event of DataGrid1_ItemD ataBound, using
    FindControl and add attributes dynamically.

    Code:

    private void DataGrid1_ItemD ataBound(object sender,
    System.Web.UI.W ebControls.Data GridItemEventAr gs e)
    {
    System.Web.UI.W ebControls.Link Button lLnkBtn_TargetB utton;

    if(e.Item.ItemT ype!=ListItemTy pe.Header&&e.It em.ItemType!=Li stItemType.Foot e
    r)
    {
    lLnkBtn_TargetB utton =
    (System.Web.UI. WebControls.Lin kButton)e.Item. Cells[2].FindControl("L inkButto
    n1");
    lLnkBtn_TargetB utton.Attribute s.Add("onclick" ,"return confirm(\"Are u
    sure?\")");
    }
    }

    Kosic


    Comment

    Working...