LinqDataSource, ListView, and DataPager example
I put together a small example in C# that demonstrates how to use the ListView, DataPager, and LinqDataSource. This example can be downloaded here. The example uses the AdventureWorks database which you can download here.

Similar Posts
- Generic List Collection / ObjectDataSource / GridView Sample
- Looking for developers for version 2.0 of the pigeon application
- Generic Sub Classes





Comments
Martillo on on 6.20.2008 at 12:23 PM
Nice! Thank you for the example. I learned a few things from it.
I especially like the way you simplified the datacontext with the POCO approach.
One issue I noticed: if you try to sort by either the BirthDate or Address columns you get a server error saying that "String.Format has no supported translation to SQL." Bummer!
I added an additional property to the anonymous type (BirthDateSort = employee.BirthDate) and then set CommandArgument="BirthDateSort" for the link button in the BirthDate column header. That fixed the BirthDate column. Figuring out the sort on the Address column would be more problematic. However, in the real world would people really want to sort on that? Maybe they'd just want a StateProvince column to sort on.
rolshan on on 6.20.2008 at 12:57 PM
Thanks for pointing that out Martillo. I fixed the sorting issue on Birth Date and removed sorting from Address since I don't see why anyone would want to sort on a formateed address. The new code is updated at the download link I provided above.
Ryan