Consider the following DataGrid:
--------------------------------------------------------------------------------
<asp:DataGrid ID="dgMarks" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateColumn>
<HeaderTemplate>
<asp:CheckBox ID="chkHeader" OnCheckedChanged="CheckUncheckAllRows"
AutoPostBack="true" runat="server"/>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkItem" OnCheckedChanged="CheckChanged"
AutoPostBack="true" runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
</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 OnCheckedChanged event
handler of the CheckBox with the ID chkItem with the following code:
--------------------------------------------------------------------------------
Sub CheckChanged(obj As Object, ea As EventArgs)
Dim chkSelHeader As CheckBox
chkSelHeader =
dgMarks.Controls(0).Controls(0).FindControl("chkHe ader")
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