Sorting Problem

2 posts, 0 answers
  1. Andy Green
    Andy Green avatar
    120 posts
    Member since:
    Jul 2009

    Posted 24 Nov 2009 Link to this post


    I have a RadGrid, datbound in code behind using a dataclass to get the data.

    I want to implement sorting and paging, but when I turn it on I get the following error in the _ItemCommand.
    Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
    I guess I need to check here that I'm actually looking at a row, If I'm correct how do I do that. If I'm wrong what do I need to do.

    This is the start of my code:
       Protected Sub rgUsers_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgUsers.ItemCommand  
            Dim User_ID As Guid = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("UserId")  
            Dim CommandName As String = e.CommandName  
            Select Case CommandName  
                Case "EditUser"  


  2. Pavlina
    Pavlina avatar
    6165 posts

    Posted 27 Nov 2009 Link to this post

    Hello Andy,

    This is most probably caused by an improper population of the control with data. The best approach in this case, is to use the NeedDataSource event handler or declarative datasource. When using declarative data sources or the NeedDataSource event, RadGrid can automatically accommodate the appropriate database operations without the need for you explicitly handle any sorting, paging, grouping, and so on.

    I hope it gets you started properly.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top