Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Access the FooterTemplates TextBox control on the Button Click Event

Reply
Thread Tools

Access the FooterTemplates TextBox control on the Button Click Event

 
 
Arulraja
Guest
Posts: n/a
 
      11-12-2003
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
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      11-13-2003
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



 
Reply With Quote
 
 
 
 
Arulraja
Guest
Posts: n/a
 
      11-13-2003
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

 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      11-14-2003
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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Building Controls 1 05-28-2004 06:23 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Datagrid Control 0 05-25-2004 01:45 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Web Controls 0 05-25-2004 01:45 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57