This is a migrated thread and some comments may be shown as answers.

GridView CurrentPosition after Sort

1 Answer 46 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 1
Sean asked on 09 Jun 2011, 01:14 PM
I've either found a bug in the RadGridView or I'm using the wrong collection.

I am leveraging the MasterTemplate.DataView.CurrentPosition in order to capture the index of the selected item, which I'm placing in a form-level variable. When this item is deleted, I want the CurrentPosition so that I can highlight the next row at that same index.

The CurrentPosition works fantastic in all instances, save for when the column is Sorted. I tried grabbing the CurrentPosition both in the SortChanged() and SortChanging() events, but the CurrentPosition property does not reflect the new location of the selected row after the sort.

I tried to circumvent this by a combination of .Refresh and <grid dataview>.IndexOf(<grid dataview>.CurrentItem), but this didn't work.

FYI: The reason I used the MasterTemplate.DataView is because this also takes into account Filtering.

Anyone's feedback would be greatly appreciated!
Sean

1 Answer, 1 is accepted

Sort by
0
Sean
Top achievements
Rank 1
answered on 09 Jun 2011, 02:51 PM
I actually was able to resolve this issue with the following code:

<gridview>.MasterTemplate.SelectedRows[0].Index

Tags
GridView
Asked by
Sean
Top achievements
Rank 1
Answers by
Sean
Top achievements
Rank 1
Share this question
or