You can try this
aspx:
Enter Eno<asp:textbox id="TextBox1" runat="server" asp:button id="Button1" runat="server" text="Added to grid" onclick="Button1_Click" />
aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
lblmsg.Text = "";
if (!Page.IsPostBack)
{
dt.Columns.Add("eno");
Session["reptable"] = dt;
GridData();
}
}
void GridData()
{
GridView1.DataSource = (DataTable)Session["reptable"];
GridView1.DataBind();
}
Add each row in the session when user add new details in the submit button
protected void Button1_Click(object sender, EventArgs e)
{
dt = (DataTable)Session["reptable"];
dr = dt.NewRow();
dr["eno"] = TextBox1.Text;
dt.Rows.Add(dr);
Session.Remove("reptable");
Session["reptable"] = dt;
GridData();
TextBox1.Text = "";
}
Hope this will help you.