该数据源不支持服务器端数据分页 [英] The data source does not support server-side data paging
本文介绍了该数据源不支持服务器端数据分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我的屏幕上的一个GridView和需要它允许分页。
I have a GridView on my screen and need it to allow paging.
标记:
<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-背后:
Code-behind:
ObjectDataSource1.SelectParameters["maximumRows"].DefaultValue = "10";
ObjectDataSource1.SelectParameters["startRowIndex"].DefaultValue = "0";
LINQ查询:
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.
我在做什么错了?
推荐答案
一个简单的了ToList()
您的结果var目录应该工作。
A simple ToList()
on your result var should work.
修改:
由于BornTo code为修正的解释
Edit: Thanks to BornToCode for a corrected explanation
的原因的错误是在数据源应该实现的ICollection。 IEnumerable的不,当你做了ToList()将它转换成一个实现ICollection的列表
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
这篇关于该数据源不支持服务器端数据分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文