views:

124

answers:

1

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.

A: 

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>
Aaron Hoffman
Aaron, I want to apply this to every table. Given your example above, how would LinqDataSource know that I want to apply the Parameter Status to the Customer table and no other. I could have a column called Status in a different table which may cause ambiguity.
Nikos
Do you want to apply this to every table or not? (I can't tell by your comment) If you do, put it on the Default List.aspx page. If you do not, create a custom page specifically for that Entity (see my original answer for a video link).
Aaron Hoffman
Thanks Aaron. After further testing, custom page is what I want based on the example that you provided.
Nikos

related questions