The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I have a DataTable as the DataSource for a GridDataBoundGrid and need the DataTable row index for the currently selected row in the grid to retrieve a value from a column that has ColumnMapping = MappingType.Hidden.
I can get this using:
private void DataGrid_CellActivated(...
...
int dataRowIndex = gdbgGrid.Binder.CurrentPosition;
...
However, double-clicking on the column header row and re-sorting the columns appears to cause this to map incorrectly back to te DataRow index.
ADAdministrator Syncfusion Team February 22, 2005 09:37 PM UTC
Once the DataTable is sorted, the rowindex in the grid no longer matches the position in the datatable. Instead, it matches the position in the sorted DataView associated with the datatable.
So, in a sorted grid, if you want the DataRow associated with the grid row whose row index is gridRowIndex, then you should use code like:
CurrencyManager cm = (CurrencyManager)this.grid.BindingContext[grid.DataSource, grid.DataMember];
DataView dv = (DataView) cm.List;
int position = this.grid.Binder.RowIndexToPosition(gridRowIndex);
DataRow dr = dv[position].Row;