0

I am able to add unlimited textbox column in a row of gridview. but after postback these textboxes get disposed. So how to retain these textboxes and their values after postback?

Code:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    int i = 3;
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        crcl = (List<string>)ViewState["bdi2"];
        foreach(string a in crcl)
        {
            TextBox TextBox101 = new TextBox();
            TextBox101.ID=a;
            TextBox101.Width = 60;
            TextBox101.Text = (e.Row.DataItem as DataRowView).Row[a].ToString();
            e.Row.Cells[i].Controls.Add(TextBox101);
            //TextBox101.AutoPostBack = true;
            i++;
        }            
    }       
} 
Sonu_Orai
  • 377
  • 2
  • 7
  • 17
  • This should help (look at the answer from rick schott): http://stackoverflow.com/questions/14216030/maintain-the-state-of-dynamically-added-user-control-on-postback – sr28 Sep 06 '16 at 12:54

1 Answers1