Reputation: 529
I have a gridview :
<asp:GridView ID="GridView1" runat="server"
ForeColor="ActiveCaptionText" BackColor="#FFFF99" GridLines="None"
onpageindexchanging="GridView1_PageIndexChanging" AllowPaging="True"
CssClass="gridrownormal" onpageindexchanged="GridView1_PageIndexChanged">
</asp:GridView>
and use this code to bind data:
GridView1.DataSource = null;
List<SearchEngineEO> docs = Search(txtSearch1.Text, ddlSelectCondition1.Text);
var query18 = (from c in docs select new { c.DocNO, c.DocType, c.Title, c.PublisherName, c.PublishedDate}).ToList().Distinct();
GridView1.DataSource = query19;
GridView1.DataBind();
if I set allowpaging to false every things is ok but when set it true ,I see this error:
"The data source does not support server-side data paging."
Upvotes: 1
Views: 1971
Reputation: 14830
That's because when you turn this property on the gridview uses its built-in paging functionality which can only work with data sources that extend the ICollection interface. ..in this case your object (query19) doesn't support it. You should be able to make it work by inverting the linq extension method calls...instead of doing this....
ToList ().Distinct ()
Do this....
Distinct().ToList()
That should work
Upvotes: 2
Reputation: 112
This may be because you are trying to fetch data using " var query18" and then assigning the value to "GridView1.DataSource" with "query19" or is it a typo ??
Another thing is try instantiating "GridView1.DataSource" instead of null.
Upvotes: 0