This is a migrated thread and some comments may be shown as answers.

Footer Controls

1 Answer 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 16 Feb 2009, 11:49 PM
I would like to retrieve the Text property of the textbox on postback but I am unable to find a way to do so.

I created a template column with a textbox in the FooterTemplate. Let's say it has an id of "txtInputInFooter".
I have tried to handle the ItemCommand event and using the following code:
Dim text As String = DirectCast(e.Item.FindControl("txtInputInFooter"), TextBox).Text
--OR--
Dim text As String = DirectCast(Me.radGrid.MasterTableView.GetItems(GridItemType.Footer)(0), GridFooterItem)("InputInFooter").Text

I get a blank value every time.

This seems like it should be a no brainer, is there something I am doing wrong?

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Feb 2009, 06:46 AM
Hi Jack,

I am not sure about what exactly is your requirement. Here i have added a button( with CommandName set) in the CommandItemTemplate and I am accessing the value of the TextBox from the FooterTemplate on clicking the button in the ItemCommand event.

ASPX:
  
 <CommandItemTemplate> 
                <asp:Button ID="Button2" runat="server"  CommandName="GetText" Text="Click" /> 
      </CommandItemTemplate> 
 
<
telerik:GridTemplateColumn UniqueName="TempCol2"  HeaderText="TempCol2" > 
                       <FooterTemplate> 
                           <asp:TextBox ID="txtInputInFooter" runat="server"></asp:TextBox> 
                       </FooterTemplate> 
                     </telerik:GridTemplateColumn> 

CS:
 
protected
 void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "GetText"
        { 
            foreach (GridFooterItem footer in RadGrid1.MasterTableView.GetItems(GridItemType.Footer)) 
            { 
                TextBox txtbx = (TextBox)footer.FindControl("txtInputInFooter"); 
                string strtxt = txtbx.Text; 
            } 
        } 
    } 


Thanks
Shinu.

Tags
Grid
Asked by
Jack
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or