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.
|
Rank: Newbie Groups: Member
Joined: 11/28/2007 Posts: 5
|
I figured out a solution - I just used the ToList LINQ extension method (duh!)
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Cool. Thanks for sharing!
|