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