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

Sorting Problem

1 Answer 35 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andy Green
Top achievements
Rank 1
Andy Green asked on 24 Nov 2009, 03:27 PM
Hi

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"  
 

Andy

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 27 Nov 2009, 11:41 AM
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,
Pavlina
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.
Tags
Grid
Asked by
Andy Green
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or