get datasource datarow by grid row index

I''m handling querycellinfo event and have row index, how to get apropriate datasource row by this index? DBG can have sorting

3 Replies

AD Administrator Syncfusion Team September 16, 2005 11:32 AM UTC

Hi, To get the corressponding record from the given rowindex, bind the grid to the datasource. The code snippet is as follows, CurrencyManager cm = (CurrencyManager) this.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember]; DataRowView drv = (DataRowView)cm.Current; DataRow dr=(DataRow)drv.Row; Regards, Leo.


SA sahon September 16, 2005 12:40 PM UTC

but this code is only for current row, how can I get row by rowindex, f.e. to process querycellinfo


SA sahon September 16, 2005 01:23 PM UTC

thank you, just found: CurrencyManager cm=(CurrencyManager)BindingContext[dtg.DataSource, dtg.DataMember]; DataRow row; DataView dv=(DataView)cm.List; if (e.RowIndex>dv.Count) return; row=dv[e.RowIndex-1].Row;

Loader.
Up arrow icon