locked
Filter out deleted records RRS feed

  • Question

  • User188291263 posted

    In my current solution,instead delete, i mark records IsDeleted = true.
    In metadata IsDeleted column (scatfold = false). But it still show in Filters.
    Also Dynamic Data generated site show those deleted records. Can I apply filter to select everything IsDeleted==false?

    I can probably override OnSelecting on LinqDataSource,but then i have to do it on each Custom page.
    Any other ideas?

    Tuesday, August 26, 2008 4:58 PM

Answers

  • User1024101778 posted

    I don't believe the ScafoldColumn applies to the FilteringRepeater.   You can accomplish this by hiding the controls.

     

                <asp:FilterRepeater ID="FilterRepeater" runat="server">
    <ItemTemplate>
    <asp:Label runat="server" Text='<%# Eval("DisplayName") %>' Visible='<%# ((string)Eval("DisplayName")).Trim() != "IsDeleted" %>' AssociatedControlID="DynamicFilter$DropDownList1" />
    <asp:DynamicFilter runat="server" ID="DynamicFilter" Visible='<%# ((string)Eval("DisplayName")).Trim() != "IsDeleted" %>' OnSelectedIndexChanged="OnFilterSelectedIndexChanged" />
    </ItemTemplate>
    <FooterTemplate><br /><br /></FooterTemplate>
    </asp:FilterRepeater>

      

    To always hide the deleted columns add a static parameter to the LinqDataSource.

      

                <asp:LinqDataSource ID="GridDataSource" runat="server" EnableDelete="true">
    <WhereParameters>
    <asp:DynamicControlParameter ControlID="FilterRepeater" />
    <asp:Parameter Name="IsDeleted" Type="Boolean" DefaultValue="false" />
    </WhereParameters>
    </asp:LinqDataSource>
     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 26, 2008 6:32 PM

All replies

  • User1024101778 posted

    I don't believe the ScafoldColumn applies to the FilteringRepeater.   You can accomplish this by hiding the controls.

     

                <asp:FilterRepeater ID="FilterRepeater" runat="server">
    <ItemTemplate>
    <asp:Label runat="server" Text='<%# Eval("DisplayName") %>' Visible='<%# ((string)Eval("DisplayName")).Trim() != "IsDeleted" %>' AssociatedControlID="DynamicFilter$DropDownList1" />
    <asp:DynamicFilter runat="server" ID="DynamicFilter" Visible='<%# ((string)Eval("DisplayName")).Trim() != "IsDeleted" %>' OnSelectedIndexChanged="OnFilterSelectedIndexChanged" />
    </ItemTemplate>
    <FooterTemplate><br /><br /></FooterTemplate>
    </asp:FilterRepeater>

      

    To always hide the deleted columns add a static parameter to the LinqDataSource.

      

                <asp:LinqDataSource ID="GridDataSource" runat="server" EnableDelete="true">
    <WhereParameters>
    <asp:DynamicControlParameter ControlID="FilterRepeater" />
    <asp:Parameter Name="IsDeleted" Type="Boolean" DefaultValue="false" />
    </WhereParameters>
    </asp:LinqDataSource>
     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 26, 2008 6:32 PM
  • User188291263 posted

    Using your sample im getting

    No property or field 'IsDeleted1' exists in type 'Product'

     

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    I dont have any IsDeleted1 property, any idea why im getting this error?

     

    Wednesday, August 27, 2008 11:48 PM
  • User1641955678 posted

    I think the reason for this behavior is that even though you hide the IsDeleted filter, it's still there and affecting the datasource.  Then when you add the explicit IsDeleted parameter, it conflicts in some way in the data source and one of them gets rename.  I know, that's a bit quirky, but I think it's something along those lines.

    I would try to get rid of that filter altogether.  If you look in the Dynamic Data Futures solution on CodePlex, it has a FilterAttribute which can do this.

    David

    Thursday, August 28, 2008 1:26 AM