471,089 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,089 software developers and data experts.

Access Control In DataGrid Header

RN1
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
Mar 8 '08 #1
1 2049
RN1
On Mar 8, 7:01*am, RN1 <r...@rediffmail.comwrote:
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
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
Mar 9 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Kaung Htut O via DotNetMonster.com | last post: by
2 posts views Thread by ChrisM | last post: by
5 posts views Thread by Paul | last post: by
1 post views Thread by Raed Sawalha | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.