You could access then easier when you are on say ItemCreated event when the
event is raised for every item. In your case you were accessing them by
looping through the Items collection so it needed bit another approach.
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Arulraja" <> wrote in message
news: om...
> Thanks a lot Teemu Keiski,
>
> I couldn't findout this information anywhere in the Net. Hopefully
> other's also will get it from your answer.
>
> Thanks
> Arul
>
>
> "Teemu Keiski" <> wrote in message
news:<#>...
> > Hi,
> >
> > //Header
> > DataGridItem header=(DataGridItem)dg.Controls[0].Controls[0];
> >
> > //Footer
> > DataGridItem footer=
> > (DataGridItem)dg.Controls[0].Controls[Controls[0].Controls.Count - 1];
> >
> > you can then search up controls from these. REason for this structure is
> > that header & footer are actually controls in DataGridTable instance
which
> > is a child control of DataGrid (DataGridTable is actually the grid
itself as
> > Table and some of the layout functionality we see in DataGrid comes from
> > this table).
> >
> > --
> > Teemu Keiski
> > MCP, Microsoft MVP (ASP.NET), AspInsiders member
> > ASP.NET Forum Moderator, AspAlliance Columnist
> >
> > "Arulraja" <> wrote in message
> > news: om...
> > > Hello,
> > >
> > > I have the following code in the .aspx file
> > >
> > > <asp:TemplateColumn HeaderText=" FG Name">
> > > <HeaderStyle ForeColor="White"></HeaderStyle>
> > > <ItemStyle HorizontalAlign="Center" Width="200px"></ItemStyle>
> > > <ItemTemplate>
> > > <asp:TextBox id=txt_fg Width="200px" Runat="server" Text='<%#
> > > DataBinder.Eval(Container,"DataItem.family_group_n ame")%>'
> > > MaxLength="100" />
> > > </ItemTemplate>
> > > <FooterTemplate>
> > > <asp:TextBox id="footerfg" Width="200px" runat="server" />
> > > </FooterTemplate>
> > > </asp:TemplateColumn>
> > >
> > >
> > > In the code behind button click event i have the follwing code
> > >
> > > foreach (DataGridItem item in grid_1.Items)
> > > {
> > > // get values from UI
> > > TextBox txtf = (TextBox)item.Cells[1].FindControl("txt_fg");
> > > }
> > >
> > >
> > > But this one is giving me only the DataGridItems(Items and
> > > ALternativeItems) not the Footer Items. If I pass the Footer TextBox
> > > ID to the FindControl method it return's a null.
> > >
> > > If I try the same code in the ItemCreated Event the TextBox "TEXT"
> > > property return's empty string.
> > >
> > > Can somebody help me to fix this problem? or Direct me how to access
> > > the Footer TextBox value on the Button Click event.
> > >
> > > Thx
> > > Arul
|