Jul 12th, 2013, 12:39 PM
Gridview RowDataBound - How to extract data from a field?
I have a situation where I have a gridview bound to a SqlDataSource. The SqlDataSource runs a query to use to populate the grid with data. So far, so good. However, I have a column in the gridview that I want to populate with data not included in the original query. To do so, I need to extract a key value from one of the cells in the gridview and use it to run another query and get the data that I need.
The problem is - I'm not able to access the data in the cells of the row during the RowDataBound event - at least not so far. Below is the code I've tried so far, along with the results:
Any ideas? Am I doing this in the wrong place or just not calling the right function?
'ID = CType(e.Row.DataItem, DataRow).Item("item_id").ToString()
'that didn't work - DataItem was nothing
'ID = e.Row.Cells(1).Text
'that didn't work - just gave me one of three things, depending upon the row it was on.:
' the column header - item_id
' an empty string
Click Here to Expand Forum to Full Width
Survey posted by VBForums.