datagrid - Selecting an item and sorting (state qu

Results 1 to 2 of 2

Thread: datagrid - Selecting an item and sorting (state qu

  1. #1
    Join Date
    Dec 1969

    Default datagrid - Selecting an item and sorting (state qu

    I have selected an item in a datagrid. Then when I sort the datagrid the selected item stays at Row(x) instead of keeping the selected item selected. In other words, if row 1 is selected, then I sort the records, row 1 remains selected when the actual data has been sorted.<BR><BR>How can I make it so the sort preserves the selected item and keeps it selected?<BR><BR>Thanks,<BR><BR>Brad

  2. #2
    Join Date
    Dec 1969

    Default RE: datagrid - Selecting an item and sorting (stat

    When you sort your data and re-bind the datagrid the "SelectedIndex" property remains the same as it was. In order to point to the desired row, you will need to adjust the datagrid.selectedIndex property to the row that you desire. Assuming that you ARE NOT USING PAGING, you will have to transverse the datasource you are binding to the grid, find the row number and set the datagrid.selectedIndex property accordingly. <BR>If you are using paging, then it becomes much more complicated as you will need to look at how to implement custom paging and assuming that you datasource is ultimately comiming from a database, you will have to restructure your query such that the desired row comes back in the desired row, or adjust you datagrid.selectedindex property....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts