2
Answers

Textbox in Dynamic Gridview

Ramco Ramco

Ramco Ramco

1y
465
1

Hi

  I have below code . Textbox is added at the end. Now i want to read its value in all Gridview rows

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
       for(int i =0; i < e.Row.Cells.Count; i++)
        {
            TextBox txt = new TextBox();
            txt.Text = e.Row.Cells[i].Text;
            e.Row.Cells[i].Text = "";
            e.Row.Cells[i].Controls.Add(txt);
        }
    }
}

Thanks

Answers (2)