We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DataGrid.Binder.CurrentPosition not accurate after re-sorting the Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

25239 Feb 22,2005 08:43 PM UTC Feb 22,2005 09:37 PM UTC WinForms 1
loading
Tags: GridControl
Dave Butler
Asked On February 22, 2005 08:43 PM UTC

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.

Administrator [Syncfusion]
Replied On 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;

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;