Welcome Guest Search | Active Topics | Sign In | Register

LINQ Query as Grid DataSource? Options
Ken
Posted: Saturday, March 7, 2009 9:07:55 PM
Rank: Newbie
Groups: Member

Joined: 11/28/2007
Posts: 5
Is it possible to use a LINQ query as a Grid DataSource?

I am trying to and getting this error when calling DataBind:

'Specified method is not supported'

I am only using LINQ as a quick way to implement pagination of a collection called AddressBook.
In the code below, friendslist is the Grid:

With friendslist
.DataSource = AddressBook
.RecordCount = AddressBook.Count
.DataBind()
End With

This works fine, but I can only ever get the first page of results to show. So I used the LINQ extension methods to grab the page of data as follows:

With friendslist
.DataSource = AddressBook.Skip(.CurrentPage * .PageSize).Take(.PageSize)
.RecordCount = AddressBook.Count
.DataBind()
End With

And now I get the error.
Ken
Posted: Saturday, March 7, 2009 9:18:09 PM
Rank: Newbie
Groups: Member

Joined: 11/28/2007
Posts: 5
I figured out a solution - I just used the ToList LINQ extension method (duh!)
eo_support
Posted: Sunday, March 8, 2009 9:19:54 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Cool. Thanks for sharing!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.