Hi,
I'm trying to understand how the WebDataGrid does paging with Ajax. I'm using the Volume 2 control for CLR 4.0
Suppose I create a SqlDataSource for, say, a view with 200 records and hook up a brand-new WebDataGrid to it. Suppose I turn EnableAjax for the grid to be true. When I run the Web app, I see (in the profiler) that the entire database is being queried just to get the first page of records, and every time I click on a different page number, the same thing is happening.
I would have expected that only a page's worth of records at a time would be grabbed. Is there a way of making this happen? My problem is that in my main program, I want to run this against a view with 13,000 records, not 200 records, and the grid takes a long time to fill for that!
Thanks for any help you can offer,
Warren
Hello Warren,
This happens because WebDataGrid requests DataSource on every postback, even when EnableDataViewState is true.
http://help.infragistics.com/NetAdvantage/ASPNET/2010.3?page=WebDataGrid_Getting_Started_with_WebDataGrid_EnableDataViewState_Property.html
EnableAjax property is enabled by default.
So as the grid requires setting DataSource , the SQL database is queried and only the current page is shown. The same will happen when you change the page index.
http://samples.infragistics.com/2010.3/WebFeatureBrowser/contents.aspx?showCode=true&t=WebDataGrid/DeclarativeDataBinding/WebDataGrid_SqlDataSource.aspx~srcview.aspx?path=~srcview.aspx?path=WebDataGrid/DeclarativeDataBinding/WebDataGrid_SqlDataSource.src
It is different when you use LinqDataSource:
http://samples.infragistics.com/2010.3/WebFeatureBrowser/contents.aspx?showCode=true&t=WebDataGrid/DeclarativeDataBinding/../../CLR35/WebDataGrid/DeclarativeDataBinding/WebDataGrid_LinqDataSource.aspx~srcview.aspx?path=~srcview.aspx?path=WebDataGrid/DeclarativeDataBinding/../../CLR35/WebDataGrid/DeclarativeDataBinding/WebDataGrid_LinqDataSource.src
Then the dataSource itself will query only the needed rows.
Please let me know if you need further assistance.