Access Control In DataGrid Header

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

    Access Control In DataGrid Header

    Consider the following DataGrid:

    --------------------------------------------------------------------------------
    <asp:DataGrid ID="dgMarks" AutoGenerateCol umns="false" runat="server">
    <Columns>
    <asp:TemplateCo lumn>
    <HeaderTemplate >
    <asp:CheckBox ID="chkHeader" OnCheckedChange d="CheckUncheck AllRows"
    AutoPostBack="t rue" runat="server"/>
    </HeaderTemplate>

    <ItemTemplate >
    <asp:CheckBox ID="chkItem" OnCheckedChange d="CheckChanged "
    AutoPostBack="t rue" runat="server"/>
    </ItemTemplate>
    </asp:TemplateCol umn>
    </Columns>
    </asp:DataGrid>
    --------------------------------------------------------------------------------

    Note that the CheckBox with the ID chkHeader is in the Header of the
    DataGrid. This CheckBox can be accessed in the OnCheckedChange d event
    handler of the CheckBox with the ID chkItem with the following code:

    --------------------------------------------------------------------------------
    Sub CheckChanged(ob j As Object, ea As EventArgs)
    Dim chkSelHeader As CheckBox

    chkSelHeader =
    dgMarks.Control s(0).Controls(0 ).FindControl(" chkHeader")
    End Sub
    --------------------------------------------------------------------------------

    If I am not mistaken, because the CheckBox with the ID chkHeader
    resides in the Header of the DataGrid, Controls(0) has been used twice
    to access this CheckBox.

    Can someone please explain me why Controls(0) been used twice to
    access the CheckBox that resides in the Header of the DataGrid (whose
    ID is chkHeader)? Which controls do the two Controls(0) refer to?

    Thanks,

    Ron
  • RN1

    #2
    Re: Access Control In DataGrid Header

    On Mar 8, 7:01 am, RN1 <r...@rediffmai l.comwrote:
    Consider the following DataGrid:
    >
    ---------------------------------------------------------------------------­-----
    <asp:DataGrid ID="dgMarks" AutoGenerateCol umns="false" runat="server">
    <Columns>
    <asp:TemplateCo lumn>
    <HeaderTemplate >
    <asp:CheckBox ID="chkHeader" OnCheckedChange d="CheckUncheck AllRows"
    AutoPostBack="t rue" runat="server"/>
    </HeaderTemplate>
    >
    <ItemTemplate >
    <asp:CheckBox ID="chkItem" OnCheckedChange d="CheckChanged "
    AutoPostBack="t rue" runat="server"/>
    </ItemTemplate>
    </asp:TemplateCol umn>
    </Columns>
    </asp:DataGrid>
    ---------------------------------------------------------------------------­-----
    >
    Note that the CheckBox with the ID chkHeader is in the Header of the
    DataGrid. This CheckBox can be accessed in the OnCheckedChange d event
    handler of the CheckBox with the ID chkItem with the following code:
    >
    ---------------------------------------------------------------------------­-----
    Sub CheckChanged(ob j As Object, ea As EventArgs)
        Dim chkSelHeader As CheckBox
    >
        chkSelHeader =
    dgMarks.Control s(0).Controls(0 ).FindControl(" chkHeader")
    End Sub
    ---------------------------------------------------------------------------­-----
    >
    If I am not mistaken, because the CheckBox with the ID chkHeader
    resides in the Header of the DataGrid, Controls(0) has been used twice
    to access this CheckBox.
    >
    Can someone please explain me why Controls(0) been used twice to
    access the CheckBox that resides in the Header of the DataGrid (whose
    ID is chkHeader)? Which controls do the two Controls(0) refer to?
    >
    Thanks,
    >
    Ron
    I don't know why but there are quite a few questions I have put
    forward in this ASP.NET newsgroup but don't get any help for them. &
    as far as my knowledge in ASP.NET (which is limited I must confess), I
    guess the questions I have been asking are pretty basic but still I
    don't get any responses for them.

    I guess there must be a severe shortage of ASP.NET MVPs, experts &
    gurus..... Since long I have been using the various Microsoft
    newsgroups like ASP, SQL Server etc. & have always got help from
    others but I don't know what's wrong with this newsgroup This
    newsgroup has indeed left a bad taste in my mouth.

    Ron

    Comment

    Working...