tags:

views:

167

answers:

2

i have a data access layer which returns data from stored procedures. If i bind this to a gridview control in asp.net 2.0, the users then have an option of filtering on that data select list where in they can choose the conditional clause of

  • like

  • =

  • or

  • and

Once the result is returned, I do not want to hit the Db again with the filters applied.

I have an option to use .net 3.5 if the need be. i looked at this: http://weblogs.asp.net/jgaylord/archive/2006/05/31/Filter-A-GridView-After-The-Initial-Bind.aspx

and not sure of its efficiency.

+1  A: 

Are you using a SqlDataSource control on the page and binding to that? if so, then you'll have to change gears and put in a manual binding step.

you might do something like storing the DataTable in ViewState or Session, then wrapping it in a DataView that contains your filter (or no filter for the intial page load). Then you just bind to the DataView.

Ben Scheirman
Brian,I am not using sqldatasource objectgridview.datasource = subsonic.storedprocedureobject.getdataset()
That's exactly what I mean. There's probably a way to do it with the data source controls, but in the end they solve the easy case, well... easy and the harder cases you might as well just bind yourself.
Ben Scheirman
+1  A: 

SubSonic Collections have filtering capabilities built-in. You can also use LINQ filters on them. I don't have specific examples here for you, but you can basically set Where clauses on subsonic collections and run a particular method (can't remember which one as I've never used this functionality) which applies the filter to the current collection and returns a new one. From what I saw, the original collection is not modified, it just has metadata to filter it in memory.

Jason Kealey