﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - WebGrid, ObjectDataSource, PagingLoadMode = Custom.  How to filter?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-ObjectDataSource-PagingLoadMode--Custom-How-to-filter/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>WebGrid, ObjectDataSource, PagingLoadMode = Custom.  How to filter?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-ObjectDataSource-PagingLoadMode--Custom-How-to-filter/</link><pubDate>Thu, 02 Sep 2010 01:17:21 GMT</pubDate><dc:creator>Glayaar</dc:creator><description>&lt;p&gt;For such scenario you could add a filter expression as a SelectParameter in the ObjectDataSource. The filter expression will hold all the WebGrid filter value. This filter expression will accept the filter syntax you created.&lt;/p&gt;&lt;p&gt; You will also need to modify the select method and selectcount method so it will accept the filter expression parameter.&lt;/p&gt;&lt;pre&gt;public DataTable GetData(string FilterExpression, int startRowIndex, int maximumRows, string sortExpression)&lt;br /&gt;&lt;br /&gt;public int GetCount(string FilterExpression, string sortExpression)&lt;/pre&gt;
&lt;p&gt;The ObjectDataSource select parameter:&lt;/p&gt;&lt;pre&gt; &amp;lt;asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete"&lt;br /&gt;      InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"&lt;br /&gt;      TypeName="dsNorthwindTableAdapters.CustomersTableAdapter" UpdateMethod="Update"&amp;gt;&lt;br /&gt;      &amp;lt;SelectParameters&amp;gt;&lt;br /&gt;          &amp;lt;asp:Parameter Name="FilterExpression" DefaultValue="" /&amp;gt;&lt;br /&gt;      &amp;lt;/SelectParameters&amp;gt;&lt;br /&gt;      ...&lt;br /&gt;&amp;lt;/asp:ObjectDataSource&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description></item><item><title>WebGrid, ObjectDataSource, PagingLoadMode = Custom.  How to filter?</title><link>http://www.intersoftsolutions.com/Community/WebGrid/WebGrid-ObjectDataSource-PagingLoadMode--Custom-How-to-filter/</link><pubDate>Wed, 01 Sep 2010 17:57:17 GMT</pubDate><dc:creator>babman</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;
&lt;p&gt;1) setting pagingloadmode="custom" in my webgrid&lt;br /&gt;2) setting assigning SelectMethod and SelectCountMethod in my ObjectDataSource.&lt;br /&gt;3) Making sure my SelectMethod has the 3 required parameters (startrowindex, maximumrows, sortexpression)&lt;/p&gt;
&lt;p&gt;So far, so good.  My webgrid selects only 100 records at a time, and sorting works fine.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;1) my total (filtered) rowcount to be incorrect - It never updates from the total (unfiltered) rowcount.&lt;br /&gt;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)&lt;/p&gt;
&lt;p&gt;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?&lt;/p&gt;
&lt;p&gt;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.  &lt;/p&gt;
&lt;p&gt;How do I then rebind my webgrid so the total matching rows is properly updated?&lt;/p&gt;
&lt;p&gt;Thanks - and I'm sorry if this is a bit confusing!&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Brian&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description></item></channel></rss>