The header and footer are a bit tricky at first, but not too bad when you
start thinking of the grid as collection of controls, which it is. Then you
simply need to search through the controls until you find the one you are
looking for.
Now, this is the basic control structure of a grid...
DataGrid
|
DataGridTable (don't ask me why this is here, but it is)
|
DataGridItems
Each DataGrid control has a single child which is the DataGridTable, it is
probably here for stylistic reasons and to confuse developers. The
DataGridTable has all the DataGridItems that make up the table, including
the heeader and footer if defined.
To get a reference to the DataGridTable for a DataGrid named dg you would do
this
dg.Controls(0)
of course you really don't care about the DataGridTable, so to get the
header control, you would do this...
Dim dgiHeader as DataGridItem = dg.Controls(0).Controls(0)
you use the 0 because the header is first control in the collection
Then you simply use .FindControl to get the child control in the header that
you need...
Dim chkRejectAll As System.Web.UI.WebControls.CheckBox
chkRejectAll = dgiHeader.FindControl("chkRejectAll")
On 8/30/05, Ronit Raj <[EMAIL PROTECTED]> wrote:
>
> hi thanks for your reply
>
> You wrote
> "You need to search in the header to get the reference to check all"
>
> Could you please tell me more about it? How can i search & all that.
>
> Thanks in advance
>
> Parvez
>
>
> Dean Fiala <[EMAIL PROTECTED]> wrote:
> chkRejectAll is in the header, it is not in an item. The list of
> items returned only represents the rows in the grid, not the header or
> footer.
>
> You need to search in the header to get the reference to check all.
>
> On 8/29/05, iceberg_collision <[EMAIL PROTECTED]> wrote:
> > Hi guys,
> >
> > I have a Datagrid control in which i have two textboxes one is in
> > <ItemTemplate> and another in the <HeaderTemplte> of the same
> > <TemplateColumn> as shown below
> >
> > <asp:TemplateColumn>
> > <HeaderStyle CssClass="contentBold"></HeaderStyle>
> > <ItemStyle CssClass="content"></ItemStyle>
> > <HeaderTemplate>
> > <asp:CheckBox ID="chkRejectAll" Runat="server"
> > AutoPostBack="True" Checked="False" OnCheckedChanged="RejectFunction"
> > Text="Reject All"
> > ForeColor="#005900"></asp:CheckBox>
> > </HeaderTemplate>
> >
> > <ItemTemplate>
> > <asp:CheckBox Checked="False" ID="chkReject"
> > Runat="server" AutoPostBack="True"></asp:CheckBox>
> > </ItemTemplate>
> > </asp:TemplateColumn>
> >
> >
> > When i call RejectFunction() then i got an error "Object Reference
> > not set to instance of an object" pointing towards the Line 9
> > Showing chkRejectAll = nothing
> > Public Sub RejectFunction(ByVal sender As System.Object, ByVal e As
> > System.EventArgs)
> >
> > Line 1. Dim rowNum As Integer
> >
> > Line 2. Dim getDataGridItem As DataGridItem
> >
> > Line 3. Dim chkRejectAll As System.Web.UI.WebControls.CheckBox
> >
> > Line 4. Dim chkReject As System.Web.UI.WebControls.CheckBox
> >
> > Line 5. For Each getDataGridItem In grdRequest.Items
> >
> > Line 6. rowNum += 1
> >
> > Line 7. chkReject = getDataGridItem.FindControl("chkReject") -------
> > ----- This is working fine
> >
> > Line 8. chkRejectAll = getDataGridItem.FindControl("chkRejectAll") ---
> > ---- chkRejectAll = nothing & producing Error.
> >
> > Line 9. If chkRejectAll.Checked = True Then
> >
> > chkReject.Checked = True
> >
> > ElseIf chkRejectAll.Checked = False Then
> >
> > chkReject.Checked = False
> >
> > End If
> >
> > item += 1
> >
> > Next
> >
> > End Sub
> >
> > End Class
> >
> > Please help me its urgent.
> >
> > Thanks in Advance
> >
> > Parvez khan
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> Dean Fiala
> Very Practical Software, Inc
> http://www.vpsw.com
>
>
> SPONSORED LINKS
> Basic programming language Computer programming languages Programming
> languages Java programming language The history of computer programming
> language
>
> ---------------------------------
> YAHOO! GROUPS LINKS
>
>
> Visit your group "AspNetAnyQuestionIsOk" on the web.
>
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>
> ---------------------------------
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> [Non-text portions of this message have been removed]
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
--
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/