如何防止gridview中动态添加的文本框在回发后进行处理

时间:2016-09-06 12:50:28

标签: c# asp.net gridview

我可以在gridview的行中添加无限制的文本框列。但在回发后这些文本框被处理掉了。那么如何在回发后保留这些文本框及其值?

代码:

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++;
        }            
    }       
}