开发者

How to avoid the refetch of records when paging button is clicked on the radgrid

开发者 https://www.devze.com 2022-12-25 17:43 出处:网络
I am using the radgrid, in my web application. I want to avoid the refetch of records when paging button is clicked on the radgrid.

I am using the radgrid, in my web application. I want to avoid the refetch of records when paging button is clicked on the radgrid.

I have a method SetTodaysAlerts which gets near about 100 records and binds to my radgrid. The page size of the radgrid is 10, hence 开发者_JAVA技巧First, Next, Previous and Last buttons are available. When I click the next button how can I avoid the re fetching of the records again.

FYI: I am using the radgrid_NeedDataSource event which does the datafetch again when any navigation button is clicked on the radgrid.


Basically you need to have one function that counts the total number of records for the query and another that selects only those that fall within the current page.

When using a RadGrid (assuming AllowCustomPaging = true) you need to first count the total number of records and save the value in the property VirtualItemCount of the RadGrid.

Now in the NeedDataSource which is called on the change of a page you need to calculate the range of records to retrieve as follows :

int firstRow = radGrid.CurrentPageIndex * radGrid.PageSize;
int maxRow   = radGrid.PageSize;

and then pass them into your query, get the results, do a set DataSource and a Rebind()

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号