日期:2014-05-19  浏览次数:20425 次

请教用GridView编写分页程序
我在页面上放了一个GridView,编写了一个DataBind函数,在装入页面时把数据绑定到了这个GridView,做了这样一个新闻管理页面,数据能够正确显示,但启用分页时提示“数据源不支持服务器端的数据分页。”在论坛里面找了相关的内容,都讲得不太全。请高手指点。如何把我的管理页面查询出来的一大串记录以分页方式显示。谢。

------解决方案--------------------
<PagerTemplate> <table align= "right " cellpadding= "0 " cellspacing= "0 " border= "0 "> <tr> <td align= "right " >
<asp:LinkButton ID= "LinkButtonFirstPage " runat= "server " CommandArgument= "First " CommandName= "Page "
Visible= " <%# ((GridView)Container.NamingContainer).PageIndex != 0 %> "> 首页 </asp:LinkButton>

<asp:LinkButton ID= "LinkButtonPreviousPage " runat= "server " CommandArgument= "Prev " CommandName= "Page "
Visible= " <%# ((GridView)Container.NamingContainer).PageIndex != 0 %> "> 上一页 </asp:LinkButton>

<asp:LinkButton ID= "LinkButtonNextPage " runat= "server " CommandArgument= "Next " CommandName= "Page "
Visible= " <%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %> "> 下一页 </asp:LinkButton>

<asp:LinkButton ID= "LinkButtonLastPage " runat= "server " CommandArgument= "Last " CommandName= "Page "
Visible= " <%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %> "> 尾页 </asp:LinkButton>
</td> </tr> </table>
</PagerTemplate>