Last post Apr 01, 2017 10:15 AM by kaushalparik27
Mar 31, 2017 12:16 PM|erum|LINK
can any one on forum edit my code that how to add textbox dynamically in grid view when btnAdd click ,please please please its very very urgent
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication5.WebForm2" %>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<asp:GridView ID="GridView1" runat="server">
<asp:Button Text="Add New" ID="btnAdd" OnClick="btnAdd_Click" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click1" />
public partial class WebForm2 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void btnAdd_Click(object sender, EventArgs e)
protected void Button1_Click1(object sender, EventArgs e)
Mar 31, 2017 01:14 PM|kaushalparik27|LINK
Can you elaborate more on your issue that you are facing? What if there are 10 rows in the GridView? Do you require to add Textbox on all those 10 rows?
Mar 31, 2017 02:31 PM|erum|LINK
as soon as user click on add button a new row added with a textbox .yes u can say 10 rows on each 10 textboxess .
Mar 31, 2017 02:34 PM|erum|LINK
i need to create rows dynamically at run time in gridview
Mar 31, 2017 02:44 PM|mgebhard|LINK
See the Web forms FAQs. It explains how to craft dynamic server controls.
Keep in mind that dynamically generated controls are not tracked by ASP Web Forms persistence. You'll need to write code to manage persistence on each and every request.
Mar 31, 2017 03:14 PM|erum|LINK
i can create but i have a problem to add in gridview
Mar 31, 2017 03:23 PM|oned_gk|LINK
place textbox in itemtmplate,
you can store datatable in session variable as the grid datasource
when click button, add new row to the datatable then rebind the grid with the datatable
Mar 31, 2017 04:56 PM|erum|LINK
Apr 01, 2017 01:24 AM|erum|LINK
Apr 01, 2017 10:15 AM|kaushalparik27|LINK
I suggest you refer to this thread:
add row and control dynamically | The ASP.NET Forums Here I have posted answer using Repeater, but you can use still same mechanism using GridView as well.