Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The data source does not support server-side data paging

I have a GridView on my screen and need it to allow paging.

Markup:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"    AutoGenerateColumns="False" DataSourceID="ObjectDataSource1">   <Columns>     <asp:BoundField DataField="appID" HeaderText="appID" SortExpression="appID" />   </Columns> </asp:GridView>  <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"    SelectMethod="GetBookingId"    TypeName="AppointmentRepository">   <SelectParameters>     <asp:Parameter Name="maximumRows" Type="Int32" />     <asp:Parameter Name="startRowIndex" Type="Int32" />   </SelectParameters> </asp:ObjectDataSource> 

Code-behind:

ObjectDataSource1.SelectParameters["maximumRows"].DefaultValue = "10"; ObjectDataSource1.SelectParameters["startRowIndex"].DefaultValue = "0"; 

LINQ query:

public IQueryable<tblAppointment> GetBookingId(int maximumRows, int startRowIndex) {     var result = (FROM a IN dc.tblAppointments                   SELECT a).Skip(startRowIndex).Take(maximumRows); } 

However I receive this error:

The data source does not support server-side data paging.

What am I doing wrong?

like image 844
ClareBear Avatar asked Nov 02 '09 13:11

ClareBear


1 Answers

A simple ToList() on your result var should work.

Edit: As explained in comments below my answer, the reason for the error is that the data source should implement ICollection. IEnumerable does not, when you do ToList() it converts it into a list which implements ICollection.

like image 87
almog.ori Avatar answered Oct 16 '22 17:10

almog.ori