getting bound row from grid row

In a databoundgrid is there a way in the PrepareStyleInfo event to get a reference to the bound row of the datatable? I thought I saw this somewhere but now can't find it.

2 Replies

AD Administrator Syncfusion Team September 12, 2002 10:13 AM UTC

You can use the currencymanager to get at the underlying datasource. To handle the problem of matching a grid row number to the correct position in the DataSource (as it might be sorted or something). you can use the Binder.RowIndexToPosition method of the grid.
Dim cm As CurrencyManager = Me.GridDataBoundGrid1.BindingContext(Me.GridDataBoundGrid1.DataSource, Me.GridDataBoundGrid1.DataMember)
	If Not cm Is Nothing Then
		' get the position in the datasource of the row in the grid
		Dim position As Integer = Me.GridDataBoundGrid1.Binder.RowIndexToPosition(e.RowIndex)
		Dim drv As DataRowView = cm.List(position)
 		'show first 3 items of the row
		'Me.Label1.Text = drv(0).ToString() + drv(1).ToString() + drv(2)
	End If


AK Andre King September 12, 2002 10:26 AM UTC

Thanks, that looks like what I need, I'll try it. do you people ever sleep? :)

Loader.
Up arrow icon