2017-02-27 42 views
0

我试图在我正在处理的应用程序中将分页添加到<asp:GridView>如何将分页添加到<asp:GridView>

这是我在遇到问题之前所尝试的。

<asp:LinqDataSource ID="Contacts" ContextTypeName="Xrm.XrmServiceContext" TableName="ContactSet" runat="server"/> 

    <asp:GridView ID="gvContacts" DataSourceID="Contacts" AutoGenerateColumns="false" 
     runat="server" GridLines="None" CssClass="table table-hover table-striped" 
     UseAccessibleHeader="true" OnPreRender="gvContacts_PreRender" AllowPaging="true" > 

     <!-- irrelevant grid view content --> 

    </asp:GridView> 

如果你忽略了AllowPaging="true",一切工作正常(无分页功能)。只要我有AllowPaging="true"我得到以下错误:

System.NotSupportedException: The method 'Count' is not supported.

如何添加分页(大小= 50)我<asp:GridView>?我在错误的轨道上还是有我失踪的东西?

回答

0

添加到您的GridView标签(排序可选):

<asp:GridView AllowPaging="true" AllowSorting="true" PageSize = "50" > 

某处你有引用的方法 “计数”。也许Linq方法.Count()的东西不可数(猜)?