[Last Call] Learn how to a build a cloud-first strategyRegister Now


Infragistics WebDataGrid - need to set filter at runtime in VB code behind form

Posted on 2009-12-17
Medium Priority
Last Modified: 2013-11-15
I am using the new WebDataGrid (V9.2.20092.2014) using VS2008  and I can figure out how to filter data at runtime. I want to allow the user to make some selections using dropdowns then apply a filter to the data when the user clicks a button. I can't figure out what I need to do in my VB code behind form.  I thought it would be something like:

Me.grdJobs.Behaviors.Filtering.ColumnFilters.Item("Profession").Condition = "Equals 'PTA'"


but the first line above gives an error.

The filtering works when I click the filter icon on the grid, select "equals","contains", etc, enter a value and hit enter but that's not what I want.

Sample code would be GREATLY appreciate. I've banged my head on the desk enough...


<ig:webdatagrid id="grdJobs" runat="server" width="650px"

            enabledataviewstate="True" stylesetname="RTT" autogeneratecolumns="False"

            datakeyfields="intJobId" ajaxindicator-enabled="true"



                                    <ig:Paging PagerAppearance="Both" PagerMode="NumericFirstLast" QuickPages="3" PageSize="25"

                                        FirstPageText="First" LastPageText="Last">






                                            <ig:ColumnFilter ColumnKey="Profession">


                                                    <ig:RuleTextNode Value="Equals COTA" />







                                    <ig:TemplateDataField Key="AddToCart" Width="75px" CssClass="table-link">


                                            Add To Cart


                                        <Header Text="Add To Cart" />


                                    <ig:BoundDataField DataFieldName="Profession" Key="Profession" Width="70px">

                                        <Header Text="Profession" />


                                    <ig:BoundDataField DataFieldName="Skill" Key="Skill" Width="80px">

                                        <Header Text="Skill" />


                                    <ig:BoundDataField DataFieldName="Shift" Key="Shift" Width="80px">

                                        <Header Text="Shift" />


                                    <ig:BoundDataField DataFieldName="Schedule" Key="Schedule" Width="80px">

                                        <Header Text="Schedule" />


                                    <ig:BoundDataField DataFieldName="JobOpeningType" Key="JobOpeningType" Width="80px">

                                        <Header Text="Job Type" />


                                    <ig:BoundDataField DataFieldName="City" Key="City" Width="100px">

                                        <Header Text="City" />


                                    <ig:BoundDataField DataFieldName="StateAbbrev" Key="StateAbbrev" Width="35px">

                                        <Header Text="State" />


                                    <ig:BoundDataField DataFieldName="Pay" Hidden="True" Key="Pay">

                                        <Header Text="Pay" />


                                    <ig:BoundDataField DataFieldName="intJobId" Hidden="True" Key="intJobId" Width="35px">

                                        <Header Text="Job ID" />


                                    <ig:TemplateDataField Key="JobDetails" CssClass="table-link">




                                        <Header Text="Details" />



                                <AjaxIndicator Enabled="True" ImageUrl="/ig_res/rtt/images/ig_progressIndicator.gif"

                                    Location="TopLeft" />


<asp:SqlDataSource ID="dataJobs" runat="server" ConnectionString="<%$ ConnectionStrings:AlexisConnectionString %>"
SelectCommand="usp_JobBoard_GetJobs" SelectCommandType="StoredProcedure" EnableCaching="True" CacheDuration="Infinite" > 
<asp:SessionParameter DefaultValue="** Not Selected **" Name="Profession" SessionField="Profession" />
<asp:SessionParameter DefaultValue="'**'" Name="State" SessionField="StateAbbrev" />
<asp:SessionParameter DefaultValue="'** Not Selected **'" Name="JobType" SessionField="JobOpeningType" />
<asp:SessionParameter DefaultValue="'** Not Selected **'" Name="Setting" SessionField="Setting" />
<asp:Parameter DefaultValue="0" Name="JobRanking" Type="Int32" />
<asp:SessionParameter DefaultValue="1" Name="PageNumber" SessionField="pageCurrent"
Type="Int32" />
<asp:Parameter DefaultValue="99999" Name="JobsPerPage" Type="Int32" />
<asp:SessionParameter DefaultValue="strStateAbbrev" Name="SortBy" SessionField="SortBy"
Type="String" />
<asp:Parameter DefaultValue="2" Name="OverrideType" Type="Int32" />
Question by:CaptBuzz
  • 2
  • 2
LVL 96

Expert Comment

by:Bob Learned
ID: 26081427
I don't have the new UltraWebGrid (still using 2007 version)...

Are you saying that you can't figure out the filtering?  Since you are using an SqlDataSource, it has FilterExpression property.

SqlDataSource.FilterExpression Property

Author Comment

ID: 26081441
I can do that & have it working. I would like to make one trip to the database, then do all filtering/sorting/paging on the webdatagrid.
LVL 96

Expert Comment

by:Bob Learned
ID: 26082195
I have never been a big fan of the complexity that Infragistics brings to its controls.  I would think that it would be easier to sort and filter the WebDataGrid with a DataView with the Sort and RowFilter properties set.

Accepted Solution

CaptBuzz earned 0 total points
ID: 26083362
I received an answer from the Infragistics forum:

Here is the example code of how you can do this from code behind:
 Dim filtering As Filtering
filtering = WebDataGrid1.Behaviors.Filtering
Dim columnFilter As ColumnFilter
columnFilter = New ColumnFilter()
columnFilter.ColumnKey = "Country"
' Depending on the column type you would use a different type of rule
' (such  as RuleNumberNode, RuleDateNode, RuleBoolNode)
columnFilter.Condition = New RuleTextNode(TextFilterRules.Equals, "Mexico")
' You can call this to have the filter condition apply right away, otherwise it
' will be applied the next time the grid dataBinds

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month17 days, 18 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question