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

[Solved] How to handle PageSizeChanged event?

1 Answer 524 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mattias
Top achievements
Rank 1
Mattias asked on 22 Dec 2009, 09:23 AM
Hi,
I'm using a RadGrid with AllowPaging=true and AllowCustomPaging=true.
The grid also has the events PageSizeChanged and PageIndexChanged enabled.

In Page_Load I'm setting the grid PageSize to 50 but when running the page it only shows 10 rows and I figure it out the cause to be in the pageSizeChanged event.
It looks like this:
       protected void radGridCompanies_PageSizeChanged(object source, Telerik.Web.UI.GridPageSizeChangedEventArgs e) 
        { 
            //_take = radGridCompanies.PageSize; 
            //Label1.Text = "ny:" + radGridCompanies.PageSize.ToString(); 
            //radGridCompanies.PageSize = e.NewPageSize; 
            //_skip = e.NewPageIndex * radGridCompanies.PageSize; 
            //radGridCompanies.PageSize = radGridCompanies.PageSize; 
 
            //_skip = 0; 
             
            radGridCompanies.CurrentPageIndex = 0; 
            //radGridCompanies.DataSource = null; 
            radGridCompanies.Rebind(); 
        } 

The grid is only showing 10 rows because of the rebind() call.

Do I need to save the grids PageSize property in ViewState or Session or something and reset it somewhere or what is best practice when using custom paging?
(thou I have tried to reset the PageSize in the event above but the then the hole page times out)

/Mattias

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 28 Dec 2009, 09:59 AM
Hi Mattias,

Thank you for contacting us and for your question.

Please, note that custom paging does not refer to assigning a custom page size to the grid but to providing in the NeedDataSource event an implementation that extracts a custom number of records from the underlying data source and assigning them to the grid structure. The PageSizeChanged and PageIndexChanged event should be used not to change the page size of the grid, but to extract any necessary information that might be needed by your application logic - such as, current and previous page size/page index, etc.

Please, take a look at the following online example (here) and do let us know if further questions arise.

Best wishes,
Tsvetoslav
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
Mattias
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or