Gridview input text field column - when i loop thru the rows, the data for that column is missing

Using C#

I have a gridview and added a template column called qty. I placed a button on the page and when clicked I call my code behind. While im looping thru the rows, all of the columns appear except the qty field. I'm assuming since I converted it to a template field that I need to do some binding to have it available in the GridView? Here is the code:

foreach (GridViewRow row in GridView2.Rows){

Response.Write("text : "+row.Cells[5].Text);

}

If I change the cell above to - row.Cells[4].text it returns the 4th column just fine, but this column is not a template field - its a regular databound field. How do I get the template field to pass within the gridview and access it?

Thanks in advance for the help - Todd

 

0
Todd
3/4/2006 9:12:54 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
1155 Views

Similar Articles

[PageSpeed] 16

The way I have done this is to use the FindeControl for the row as follows:

Dim txtMyTextbox As TextBox

txtMyTextbox = CType(row.FindControl("txtNameOfTemplateItem"), TextBox)

If (Not txtMyTextbox is nothing) then

response.write(txtMyTextbox.Text)

endif

hope this helps...

0
nitewalker
3/5/2006 12:23:01 AM
Thanks - this ended up working out for me, appreciate the feedback.
0
Todd
3/9/2006 1:12:11 AM
Reply: