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

RadGrid + MVP => 2xSelectMethod call

2 Answers 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aleksejs
Top achievements
Rank 1
Aleksejs asked on 12 Jan 2015, 10:19 AM
Hi,

I'm facing very odd behavior with RadGrid and WebForms MVP. Long story short is that during paging ObjectDatasource calls for Select method twice. 

I compared it with standard ASP GridView and it works well, just a single call. Can please somebody tell me a secret - why is that happening?

I'm attaching an example website solution with examples of RadGrid (radgrid.aspx) and GridView (AspGridView.aspx), both userControls have the same codeBehind, difference is only in grid (radGrid or GridView). Just put a breakpoint on Select method, and you will notice that every time you change the page in Telerik's grid, datasource is being asked twice.

https://drive.google.com/file/d/0B3Da7JHcNzvcNGdrU2lna3BFYUE/view?usp=sharing

Thank you

2 Answers, 1 is accepted

Sort by
0
Aleksejs
Top achievements
Rank 1
answered on 12 Jan 2015, 10:39 AM
Update:

I've noticed that enabling viewState removes that second call to SelectMethod.
But question is still opened, why is that happening only for RadGrid?
0
Vasil
Telerik team
answered on 14 Jan 2015, 01:38 PM
Hi Aleksejs,

It depends on the implementation of your ObjectDataSource and type of the returned collection of data. In general case, the grid will make one request that just returns the Count of items, to build the pager of the grid. And another request to get the items of the current page.

More over, if the ViewState is disabled. During PostBack, the grid will need the DataSource, in order to recreate the items correctly. And then another request for data during rendering (assuming that the data can be changed meanwhile, because of edit/delete/inserts). If the ViewState is enabled, during initialize the old data will be used for recreating it's structure.

Regards,
Vasil
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Aleksejs
Top achievements
Rank 1
Answers by
Aleksejs
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or