locked
Default filter in background RRS feed

  • Question

  • User1980140492 posted

    Dear readers,

    Is it possible to have a default base filter on a table? Say I have an product table with a state field which can have "Active" or "Inactive" as values.

    I'd like to show the users at all time ONLY the active products.

    Thanks in advance,
    Yannick

    Tuesday, June 21, 2011 10:00 AM

Answers

  • User-330204900 posted

    Hi Yannick, yes this is possible,  all you need to do is create a custom page (or use the generic page template if all table have this column) and the in the QueryExtender add this;

    <asp:QueryExtender TargetControlID="GridDataSource" ID="GridQueryExtender" runat="server">
        <asp:DynamicFilterExpression ControlID="FilterRepeater" />
        <asp:PropertyExpression>
            <asp:Parameter DbType="Boolean" Name="Discontinued" DefaultValue="false" />
        </asp:PropertyExpression>
    </asp:QueryExtender>

     Here I have added a PropertyExpression and to that added a Parameter and set its value. you can find out more about QueryExtender here QueryExtender
    Class (System.Web.UI.WebControls)

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 22, 2011 4:57 AM
  • User-330204900 posted

    Hi Yannick, you will need to have a look at my cascade sample on my blog here C# Bits just search for Cascade, I am working on adding Cadcade to NuGet in the next week or so so it will be much easier to implement in your own projects.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 24, 2011 8:46 AM
  • User-330204900 posted

    I will only be making it work with VS2010 and .Net 4 for NuGet the earlier version is available via my SkyDrive Public folder

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 24, 2011 10:57 AM

All replies

  • User1980140492 posted

    Anyone?

    It's kinda urgent :P

    Thanks in advance,
    -Yannick

    Wednesday, June 22, 2011 2:25 AM
  • User-330204900 posted

    Hi Yannick, yes this is possible,  all you need to do is create a custom page (or use the generic page template if all table have this column) and the in the QueryExtender add this;

    <asp:QueryExtender TargetControlID="GridDataSource" ID="GridQueryExtender" runat="server">
        <asp:DynamicFilterExpression ControlID="FilterRepeater" />
        <asp:PropertyExpression>
            <asp:Parameter DbType="Boolean" Name="Discontinued" DefaultValue="false" />
        </asp:PropertyExpression>
    </asp:QueryExtender>

     Here I have added a PropertyExpression and to that added a Parameter and set its value. you can find out more about QueryExtender here QueryExtender
    Class (System.Web.UI.WebControls)

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 22, 2011 4:57 AM
  • User1980140492 posted

    Thanks a bunch :) helped a lot.

    Now I'm facing another issue concerning filtering that happens in the background.

    Imagine the following 2 tables:

    ARTICLE:
    - ID ( PK )
    - Name
    - GroupID ( PK ) ==> Just think this is an int that can be 1 to 10.

    ARTICLE-RELATION:
    - Parent_ID ( FK to ARTICLE.ID )
    - Child_ID ( FK to ARTICLE.ID )
    - GroupID ( used by both above FK's )

    Now in my dynamic data page they'll create ARTICLE-RELATIONS.
    When they fill in the first value ( GroupID ) the 2 reference fields to ARTICLE should show a filtered list with ARTICLES where the GroupID is the one that is already filled in.

    I hope it's clear.

    Thanks in advance,
    -Yannick

    Friday, June 24, 2011 8:09 AM
  • User-330204900 posted

    Hi Yannick, you will need to have a look at my cascade sample on my blog here C# Bits just search for Cascade, I am working on adding Cadcade to NuGet in the next week or so so it will be much easier to implement in your own projects.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 24, 2011 8:46 AM
  • User1980140492 posted

    Your link wasn't working, but I guess you mean this one ( + the other parts ):
    http://csharpbits.notaclue.net/2010/06/part-3-cascading-hierarchical-field.html

    I like what I'm seeing, but will this work for both VS2008 + .NET 3.5 and VS2010 + .NET 4.0 ?

    Kind regards,
    - Yannick

    Friday, June 24, 2011 9:45 AM
  • User-330204900 posted

    you'll notice the none of the download are working on my blog now this is as a result of Live.com making SkyDrive better and messed up all the links now none work.

    See my post from yesterday for my public folder

    Friday, June 24, 2011 9:59 AM
  • User1980140492 posted

    Owkay no problem, it's weekend anyway :)

    But will this cascading filtering work for both VS2008 + .NET 3.5 and VS2010 + .NET 4.0 ?

    Regards,
    - Yannick

    Friday, June 24, 2011 10:18 AM
  • User-330204900 posted

    I will only be making it work with VS2010 and .Net 4 for NuGet the earlier version is available via my SkyDrive Public folder

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 24, 2011 10:57 AM