Can WebDataGrid's (with filtering, sorting, and paging) work with datasets?
I ask because my project calls a DLL that returns various datasets. I then point the WDG at the dataset. It loads initally, but filtering, sorting, and paging don't work, and sometimes blanks it out.
I've created a very simple dummy website and attached it, hoping you can steer me in the right direction. Thanks.
Hello,
Yes the grid does work with data sets.
In your sample you bind it on a button click. Yet by default the grid needs an access to the data source on every page load to perform these operations. So you might want to consider assigning the DataSource property on every page load (no need to call DataBind()).
If you'd like the grid to place all of the data into the view state then the EnableDataViewState ptoperty should be set to True and data binding code left as is. However in this case the grid will use internal functionality to sort/filter the data and on PageIndexChange the data source still must be provided as the grid will not place the entire data source into the view state, only the rows it is bound to.
I played with what you mentioned and it worked. Though in my real apps (1000's of rows) ViewState isn't feasible, so I thought I'd use Cache. I tweaked my dummy webapp and attached it. I have 2 questions based on it...
1) Assuming I'll work with large datasets, would you consider using the Cache to be a good practice so I don't keep hitting the DB? If not, please tell me what "best practice" changes I should make.
2) As you recommended, I'm no longer using Databind. Why should I not use it?
By cache I assume you mean the page cache? Using cache with the dynamic controls which state is changed from post back to post back is not really a good idea as they may be changing and the cache will always restore its original values.
I'd recommend still using the view state but not storing it on the page, but consider alternative storages:
http://www.hanselman.com/blog/MovingViewStateToTheSessionObjectAndMoreWrongheadedness.aspx
http://aspalliance.com/articleViewer.aspx?aId=135&pId=
DataBind() is called automatically by the grid after onprerender. If you call it yourself it should not be a big deal, the grid will simply skip it call.
For the life of me I cannot get the "new and improved" Web Data Grid to work as described in your reply.
I have a search form which takes a bunch of inputs.The user clicks on the submit button which executes a function that returns a dataset.This dataset is then bound to the Grid Control during this server side click event.The results are displayed in the Grid.--- This is where the good part ends and the bad part begins ---
I cannot get the paging, sorting or filtering to work "out of the box". It appears that perhaps there is a considerable amount of coding that must be required in order to wire up all the proper events correctly. No where on this site have I found anyone providing actual code examples of how to get paging, sorting and fitlering working with the Web Data Grid (Aikido framework) NOT the old Ultra Web Data Grid.It would be nice if Infragistics would supply such an example where data is not bound on Page_Load but rather when a button is clicked.While I'm at it, my client also wants to have this Grid be exportable to Excel. I tried but failed there as well. I think these are not unreasonable requests that should be readily available as downloadable code snippets?
If the data is supplied on a button click it should be placed into the viewstate otherwise the grid will lose it on the next post back.
Setting the EnableDataViewState property should take care of that.
By default however the grid requires the data source to be provided on every post back. This allows better optimization and reuse of such common operations as sorting, paging etc. which are provided by certain data sources. Setting EnableDataViewState instructs the grid to maintan the data in its internal collection, which means sorting, paging etc is done by the grid and the view state is a lot bigger.
The grid currently does not support exporting to excel out of the box. There are some articles however that show how to do that. For ex: http://community.infragistics.com/blogs/taz_abdeali/archive/2008/12/12/webdatagrid-how-to-import-data-from-excel-amp-amp-export-to-excel-pdf-or-xps.aspx