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

Posted on 2009-12-17
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
    LVL 96

    Expert Comment

    by:Bob Learned
    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

    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
    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

    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

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now