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

Dynamic text box in Edit form template

1 Answer 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adonis
Top achievements
Rank 1
Adonis asked on 06 Oct 2010, 01:19 AM
 I am trying to add dynamic text boxes inside of a edit form popup from radgrid, in a manner where a user can hit "add new text box" button and another text box for data entry would appear. I Have found a sample of code that does this in VB I am looking for some guidance on how this can be accomplished in the edit form template  

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Oct 2010, 06:59 AM
Hello Adonis,

You can achieve this by creating one TextBox in EditItemTemplate and initially set its visibility as 'False'. Then when clicking on the 'add new textbox' button set its visibility as 'true'.

ASPX:
<telerik:GridTemplateColumn>
   <EditItemTemplate>
     <asp:TextBox ID="TextBox1" runat="server" Visible="false"></asp:TextBox>
     <asp:Button ID="Button4" runat="server" Text="add new textbox" CommandName="AddTextBox" />
   </EditItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
   {
     if (e.CommandName == "AddTextBox")
       {
           Button button = (Button)e.CommandSource;
           GridEditFormItem editItem = (GridEditFormItem)button.NamingContainer;
           TextBox txt = (TextBox)editItem.FindControl("TextBox1");
           txt.Visible = true;
       }
   }

Thanks,
Princy.
Tags
Grid
Asked by
Adonis
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or