Ramco Ramco

Ramco Ramco

  • 419
  • 3.4k
  • 528.3k

Textbox in Dynamic Gridview

May 5 2023 11:18 AM

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)