C# – Custom Paging with Radgrid not working

asp.netcradgridtelerik

I was looking at the answers from different questions here but cant get to something that I can use, I am new to the RadGrid stuff had always used GridView but now, they changed them all to RadGrids and one of them needs to have the paging custom, there is an example here and I am trying to use it but i am not sure how to do it if my data source is a data set see below

                AdminManager adminMan = new AdminManager();
                DataSet ds = adminMan.GetProducts();

                int startRowIndex = (ShouldApplySortFilterOrGroup()) ?
                   0 : Grid.CurrentPageIndex * Grid.PageSize;


                int maximumRows = (ShouldApplySortFilterOrGroup()) ?
   **HERE NOT SURE HOW TO TRANSLATE THIS SO THAT I CAN USE IT
                     MyBusinessObjectCollection1.SelectCount() : RadGrid1.PageSize;**

                Grid.AllowCustomPaging = !ShouldApplySortFilterOrGroup();

      **HERE NOT SURE HOW TO TRANSLATE THIS SO THAT I CAN USE IT
              RadGrid1.DataSource = MyBusinessObjectCollection1.Select(startRowIndex, maximumRows);**

As you can see i am not sure how to trnaslate that example code when using a data set. See the parts where I am noting "Here not sure how to translate…." Any help would be appreciated.

Regards

Best Answer

I'm a little confused to the problem, so I'm going to include my example of what DID work, and maybe that will help you in your endeavor. To start, I set these on the grid:

<!-- Set pageSize to whatever you want -->
<tel:RadGrid .. AllowPaging="true" AllowCustomPaging="true" PageSize="10" />

In code, when time to bind, i do this:

//need to pass the total number of records there are; this is used to build
//the paging list
this.RadGrid1.VirtualItemCount = totalNumberOfRows;

//Bind the filtered resultset that has only 10 or whatever the page size amount of records are
this.RadGrid1.DataSource = x;
this.RadGrid1.DataBind();

Essentially, you bind the filtered result, but set the virtual item count to the total number of records. The RadGrid should also support binding to a DataSet as well, so that shouldn't be a problem.

Related Topic