Selected Rows Order

2 posts, 1 answers
  1. lampy
    lampy avatar
    47 posts
    Member since:
    Oct 2006

    Posted 21 May 2008 Link to this post

    Hello,

    I have an app where I move rows between grids.  I have run into an issue because it seems like the order of grid.SelectedItems is random and not in the order of how the user clicked them  Is there a way to get grid.SelectedItems in the order of how the user clicked them?  Right now the only option is to roll my own functionality by using the row selected client event to capture the order and store it in a hidden field that I access server side to add the other grid.  I rather not do this if there is a solution or a better way accomplish this.  Any idea?

    Thanks
  2. Answer
    Veli
    Admin
    Veli avatar
    2002 posts

    Posted 27 May 2008 Link to this post

    Hello lampy,

    The RadGrid.SelectedItems collection stores the indexes of the selected items in the order they are selected. To demonstrate, please follow these steps:

    1. Set  EnablePostBackOnRowClick="true" in the ClientSettings of RadGrid
    2. Subscribe to the ItemCommand event
    3. Place the following code in the ItemCommand event handler:

    if (e.CommandName == "RowClick"
        for(int i=0; i<RadGrid1.SelectedItems.Count; i++) 
        Response.Write(RadGrid1.SelectedItems[i].RowIndex.ToString()); 

    When you click on a row and the page makes a postback, you will see the indexes of the selected items enumerated in the order they are selected.

    Regards,
    Veli
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top