Wednesday, May 21, 2008

How to add a textbox inside a gridview

First add a gridview in your page and go to the source view of your page and find the gridview inside which you want to add the textbox and you can insert a code as below (the one in bold blue color) and it will add the textbox into the gridview when it is bound to the database object.

-------------------------------------------------------------
Just below it is the code with which you can access these individual textbox in the different rows.
-------------------------------------------------------------------------------------
for (int j = 0; j < GridView1.Rows.Count; j++)
{
Control cnt;
cnt = GridView1.Rows[j].Cells[3].Controls[1];
cnt = GridView1.Rows[j].FindControl("txtValue");
TextBox txtBx = (TextBox)cnt;
//write your code here to maniupulate the content of textbox



}

No comments: