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

Using RadTextBox in RadGrid Footer

1 Answer 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Doug
Top achievements
Rank 1
Doug asked on 06 Mar 2009, 09:10 PM
I am using a RadTextBox in a RadGrid Footer for insert.  I added an Insert button as well.  My Server side code in the grid_ItemCommand event grabs the footer item by e.Item.  I then search for my RadTextBox via footer.FindControl("txtName").
That function call returns me an object with the correct ID.  The ClientID matches the HTML as well.  However the Text that was entered does not get populated in the txtName.Text property.

I can get the text from request.form(txtName.ClientID & "_text").  It's a work-around but it's not the best solution.

Thanks,
Doug

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Mar 2009, 07:53 AM
Hi Doug,

I tried this on my end and it is working as expected. Give a try with the code snippet given below and see if it works.

ASPX:
  
 
<telerik:GridTemplateColumn UniqueName="TempCol" DataField="ProductName"    HeaderText="TempCol" > 
                  <ItemTemplate> 
                      <b><%# Eval("ProductName")%></b
                  </ItemTemplate> 
                  <FooterTemplate> 
                      <telerik:RadTextBox ID="txtName" runat="server"
                      </telerik:RadTextBox> 
                      <asp:Button ID="Button3" runat="server" Text="Insert"  CommandName="InsertText" /> 
                  </FooterTemplate> 
                </telerik:GridTemplateColumn> 

CS:
 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "InsertText"
        { 
            GridFooterItem footer = (GridFooterItem)e.Item; 
            RadTextBox txtbx = (RadTextBox)footer.FindControl("txtName"); 
            string strName = txtbx.Text; 
        } 
   } 


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