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.

1
  • could you tag this as "asp.net-dynamic-data" also/instead Commented Jul 8, 2009 at 18:08

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

3 Comments

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.
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).
Thanks Aaron. After further testing, custom page is what I want based on the example that you provided.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.