I'm using Telerik RadGrid to present some objects to user. When the grid is filled thru NeedDataSource event, everything works fine. But I'm experimenting with asynchronous data loading and binding data to grid thru RadGrid.Datasource seems better for this.
My problem is that when I bind data this way - setting RadGrid.Datasource and calling RadGrid.DataBind(), than the DropDown list for choosing PageSize stops showing the selected pagesize. The dropdown list alone works fine, I can change to different number of items per page, but no matter what i do, the number is not visible.
Sorting and filtering of the data is done in WCF service, so I have set AllowCustomPaging to true and I set the VirtualItemCount just after setting the DataSource property (just before calling DataBind()).
The grid then looks like this:
5 Answers, 1 is accepted
The following online example shows the steps on how to implement simple data-binding with paging. You need to bind the grid on page load and in the PageIndexChanged event handler as shown below:
the Telerik team
Thank you for your answer, but unfortunately, this won't solve my problem. As I wrote before, I'm trying to load data for the grid asynchronously, using PageAsyncTask and page.RegisterAsyncTask. This way I have the data for grid available sometime between Page_PreRender and Page_PreRenderComplete. Problem is that when I try to bind the data in Page_PreRenderComplete (when it's sure I have them available) then I end up with InvalidOperationException - "Script controls may not be registered after PreRender". It doesn't matter whether I use RadGridList.DataSource or bind them thru NeedDataSource event and RadGrid.Rebind.
Only work-around I found is binding the data in the moment I have them available - which is after PreRender but still before PreRenderComplete. This way I can bind them to the grid, without experiencing the exception (as is seen on the image I posted before).
Only problem which remains (and that is why I started this thread) is that the DropDown text which should present the number of items per page stays empty.
I tried now to implement the same (binding the data when they arrive, before the Page_PreRenderComplete event) through the NeedDataSource event and it works for me too, but does the same thing with the DropDown text.
I will probably attach some source code to explain this better.
This is some "explaining" class to show how I have implemented the binding of the grid:
Can you please open a formal support ticket and send a runnable version of your project for us to debug locally and make the needed changes, so that it behaves as expected.
Other than this it is hard to determine the source of the problem based on the provided code.
the Telerik team