Reputation:
If you followed my previous post
var filteredUser = from U in collection
select new {U.fname,U.lname};
gridView.DataSource = filteredUser;
gridView.DataBind();
Now I am trying to do this:
Format the column names based on properties of U. So for example if U.fname chancges to U.FirstName then I want my gridview column name to reflect the same
If I enable paging through the design view, code compiles but when I launch the web app, it fails stating 'The data source does not support server-side data paging'
Edit::Found this for item # 2 link text
Upvotes: 0
Views: 713
Reputation: 532445
1) Are you using AutoGenerateColumns="True"
on your GridView or binding them yourself? I would think that (1) would work if AutoGenerateColumns
is true. You lose a lot of control over how the columns are displayed, but it ought to work. If you are binding them yourself, I think you will just need to update the bound column names whenever the name of the data field changes or alias the name in the select
clause so that it remains the same.
var filteredUser = from U in collection
select new {FirstName = U.fname, LastName = U.lname};
2) Does your collection support IEnumerable<U>
or just IEnumerable
? I believe that LINQ uses Skip()
and Take()
to support paging so it would need to support the generic enumerable interface.
Upvotes: 1