ASP.NET Dynamic Data Record Selection

asp.net-dynamic-datadynamic-data

I am displaying a list of customer records from SQL Server using L2S where I only want to display active customers (where Status = 'A'). How do I implement this logic in Dynamic Data? I am using the List.aspx template. I don't want the dropdown filtering option.

Best Answer

You can do this by adding a Parameter to the LinqDataSource's WhereParameters collection.

If you don't want this for every table, you'll have to create a custom page for that Entity, and add it only on that page. (video http://www.asp.net/Learn/3.5-SP1/video-445.aspx)

<asp:LinqDataSource ID="GridDataSource" runat="server" EnableDelete="true" EnableUpdate="true">
    <WhereParameters>
        <asp:DynamicControlParameter ControlId="FilterRepeater" />
        <asp:Parameter Name="Status" DefaultValue="A" />
    </WhereParameters>
</asp:LinqDataSource>
Related Topic