WebGrid, ObjectDataSource, PagingLoadMode = Custom. How to filter?

1 reply. Last post: September 2, 2010 1:17 AM by Glenn Layaar
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
Brian BakerMember

Hi,

I am connecting a webgrid to a table that contains about 100,000 records via an ObjectDataSource.  I'm doing my own server-side paging by:

1) setting pagingloadmode="custom" in my webgrid
2) setting assigning SelectMethod and SelectCountMethod in my ObjectDataSource.
3) Making sure my SelectMethod has the 3 required parameters (startrowindex, maximumrows, sortexpression)

So far, so good.  My webgrid selects only 100 records at a time, and sorting works fine.

Now I want to allow the user to be able to filter on any column in the webgrid.  However, using only the built-in feature of the webgrid causes some problems.

1) my total (filtered) rowcount to be incorrect - It never updates from the total (unfiltered) rowcount.
2) my grid doesn't show the first 100 filtered records.  It shows only the subset of the first 100 records that match my filter.  Or, if I scroll down to get a second page of data (which would show rows 1 through 200 if I had no filter)

Do I have to force the webgrid to rebind in order to get the correct number of total rows that match my filter?  Where would I do this?  Also, do I have to try to recreate the filter syntax by iterating through each of the filteredcolumns in my webgrid's roottable?

I've tried to do just that by iterating through all the webgrid's roottable's filteredcoulmns and creating filter syntax that my database would accept within objectdatasource1_selecting.  I then add this filter to my httpcontext.current.items.  Within my SelectMethod (which has to have only startrowindex, maximumrows, and sortexpression since it is used by my objectdatasource), I grab the filter syntax from my httpcontext.current.items and pass it to my stored procedure. 

How do I then rebind my webgrid so the total matching rows is properly updated?

Thanks - and I'm sorry if this is a bit confusing!

 

Brian

 

 

 

 

All times are GMT -5. The time now is 3:39 AM.
Previous Next