I have a RadGrid where I do not use an ObjectDataSource but set its DataSource programmatically with a DataSet. I have turned on both sorting and paging and have experienced a problem. When I page through the results, everything is fine. However, if I click on a column to sort the data and then click on a page number, I receive the following error:
index 10 is either above negative or above rows count radcontrol
"10" is the page size of my RadGrid.
I have used paging and sorting together in a regular GridView where an ObjectDataSource was not used, and I had to add custom coding to handle the sorting and paging events. Is there anything special I have to do when using sorting and paging with the RadGrid and a programmatic datasource? If so, do you have any example code. I couldn't find anything in the documentation about this.
Because I am using a programmatic data source, I have to reload the data each time a grid page is changed or sort is called. But I am not doing anything more than that at this time. Do I need to reset the CurrentPageIndex or other properties so that the sorting doesn't conflict with the paging? Also, the sorting and paging are not being done by a postback but through Ajax. Is there something on the client side that might explain this problem? (By the way, how can I turn off Ajax and just have the sorting and paging occur through postbacks? I can't seem to find the EnableAjax property in the RadGrid control.)
Any help would be greatly appreciated.
Here is a snippet of the code:
<telerik:RadGrid runat="server" ID="grdSchool" AllowPaging="True" AutoGenerateColumns="False"
GridLines="None" Skin="aspire" EnableEmbeddedSkins="false" PageSize="10" Width="100%"
OnItemDataBound="grdSchool_ItemDataBound" OnItemCommand="grdSchool_ItemCommand"
AllowSorting="True" OnSortCommand="grdSchool_OnSort" OnDeleteCommand="grdSchool_DeleteCommand"
OnPageIndexChanged="grdSchool_PageChanged" PagerStyle-Mode=NextPrevAndNumeric>
<MasterTableView>
etc.
The grdSchool_OnSort and grdSchool_PageChanged methods simply get the data from the session, set the DataSource, and then rebind.