finding Unique ID for rows in a datagrid while the data is binding! May 04 2004
Another one of those freaky VB.NET things is trying to determine the unique DB identifier for a datagrid row while the datagrid is bound to a data
set.
I used the OnItemDataBoundEventHandler to pick up the unique ID by recovering the bound data set and the index associated with the current item.
This is one of those M$ voodoo tricks I guess?
=== BEGIN ===
Private Sub dgInodeList_OnItemDataBoundEventHandler( _
ByVal sender As System.Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles dgInodeList.ItemDataBound
‘ Get the data source for the Data Grid, in this case a DataSet
Dim ds As New DataSet
ds = dgInodeList.DataSource
‘ Get the current line we are binding data for
Dim intItemIndex As Integer = 0
intItemIndex = e.Item.ItemIndex
‘ Determine the unique id for this row in the dataset
Dim inode_id As Integer = 0
inode_id = ds.Tables(0).Rows(intItemIndex).Item(0)
end sub
=== END ===
UPDATE : I found the solution to this stupid problem! Took me a while
- Posted in : .NET
- Author : site admin

Comments»
no comments yet - be the first?