NET 3.5 and talked about how you can use it to easily bind ASP. I also demonstrated how to use it a little more in a follow-up post I did that discusses the new control (Part 1 - Building a Product Listing Page with Clean CSS UI).
In both of these articles the queries I performed were relatively straight-forward (the where clause worked against a single table of data).
For example, assuming we had created a LINQ to SQL data model for the Northwind database (which I covered how to-do in Part 2 of this series), we could declare a control at the datasource and enable paging, editing, and sorting on it: When we run the above page we'll then have a Grid View with automatic sorting, paging, and editing support against our Product data model: Using declarative parameters like above works well for many common scenarios.
But what happens if you want the Product filtering to be richer or more complex?
For example, what if we only wanted to display products made by suppliers based in a dynamic set of countries?
To handle custom query scenarios you can implement an event handler to handle the "Selecting" event on the control.
Over the last few weeks I've been writing a series of blog posts that cover LINQ to SQL.
LINQ to SQL is a built-in O/RM (object relational mapper) that ships in the .NET Framework 3.5 release, and which enables you to model relational databases using . You can use LINQ expressions to query the database with them, as well as update/insert/delete data.Below are the first eight parts in this series: control in .Within this event handler you can write whatever code you want to retrieve a data model result.You could do this with a LINQ to SQL query expression, or call a Stored Procedure or use a Custom SQL Expression to retrieve the LINQ to SQL data model.Once you retrieve a sequence of data, all you need to-do is to assign it to the "Result" property on the Linq Data Source Select Event Args object.