GridView and TextBox value (FindControl)

Trips

Well-known member
Joined
Aug 7, 2010
Messages
2,788
I added text box into GridView using this code
foreach (GridViewRow grv in gv.Rows)<br/>
{<br/>
TextBox tb = new TextBox();<br/>
tb.ID = "TextBox" + j++;<br/>
gv.Rows[i++].Cells[2].Controls.Add(tb);<br/>
}
Now I am trying to read value entered in this text box in next foreach loop when submit button clicked event and not able to do it. how do you read?
I am trying to read this
foreach (GridViewRow grv in gv.Rows)<br/>
{<span style="font-size:x-small; color:#2b91af <span style="font-size:x-small; color:#2b91af TextBox<span style="font-size:x-small _test = (<span style="font-size:x-small; color:#2b91af <span style="font-size:x-small; color:#2b91af TextBox<span style="font-size:x-small )
grv.FindControl(<span style="font-size:x-small; color:#a31515 <span style="font-size:x-small; color:#a31515 "TextBox"<span style="font-size:x-small + j++);}
<span style="font-size:x-small Why _test is coming null?
<span style="font-size:x-small Thank you.

View the full article
 
Back
Top