Hi, I've been bashing my head against this for a while now so perhaps someone could point me in the right direction. Hopefully, it's blindingly obvious but I've only been playing with this stuff for a few days. I'm doing some conversion of underlying table
(well a storedproc actually) data into a textual format inside the _ItemDataBound event for my DataGrid. What would be useful would be access to the row that corresponds to this Item. I realize that I can access the DataSet, but I'm unclear how to associate
the row being processed in the ItemDataBound with it's corresponding row in the dataset. Can someone offer a suggestion please?
assuming you're not doing any filtering on the dataset before binding it to the control, you should be able to get the index of the row by using:
Dim myRow as integer
myRow = e.item.itemindex
you should then be able to access the row in the dataset with the following
Dim drow as DataRow
drow = myDataSet.Tables("myTable").rows(myRow)
If you are filtering the dataset before binding it to the controls, you will need to use the DataKeys property (assuming you;re using a datagrid control or similar) to specify a unique row identifier, and then search or filter the dataset using the datakey as a parameter.
to get the datakey of a row in a datagrid in itemDataBound, use the following code
devlinse
Member
10 Points
2 Posts
Access to the relevant DB row inside an ItemDataBound event
Oct 24, 2003 09:33 AM|LINK
Glosh
Member
445 Points
89 Posts
Re: Access to the relevant DB row inside an ItemDataBound event
Oct 24, 2003 10:29 AM|LINK
Dim drow as DataRow drow = myDataSet.Tables("myTable").rows(myRow)If you are filtering the dataset before binding it to the controls, you will need to use the DataKeys property (assuming you;re using a datagrid control or similar) to specify a unique row identifier, and then search or filter the dataset using the datakey as a parameter. to get the datakey of a row in a datagrid in itemDataBound, use the following code Cheers Markdevlinse
Member
10 Points
2 Posts
Re: Access to the relevant DB row inside an ItemDataBound event
Oct 25, 2003 10:05 AM|LINK