Gridview 绑定自定义页面模板
2010-09-17 09:01
387 查看
要在页脚显示如总页数的信息,你可以用<PagerTemplate>项,如下例所示:
<asp:GridView ID="GridView1" runat="server"
DataSourceID="SqlDataSource1"
DataKeyNames="ID"
AllowPaging="true"
PageSize="10"
AutoGenerateColumns="true">
<PagerTemplate>
<asp:Label ID="LabelCurrentPage" runat="server"
Text="<%# ((GridView)Container.NamingContainer).PageIndex + 1 %>">
</asp:Label>/
<asp:Label ID="LabelPageCount" runat="server"
Text="<%# ((GridView)Container.NamingContainer).PageCount %>">
</asp:Label>
<asp:LinkButton ID="LinkButtonFirstPage" runat="server"
CommandArgument="First"
CommandName="Page"
enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0
%>"><<
asp:LinkButton ID="LinkButtonPreviousPage" runat="server"
CommandArgument="Prev" CommandName="Page"
enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>"><
</asp:LinkButton>
<asp:LinkButton ID="LinkButtonNextPage" runat="server"
CommandArgument="Next"
CommandName="Page"
enabled="<%# ((GridView)Container.NamingContainer).PageIndex !=
((GridView)Container.NamingContainer).PageCount - 1 %>">>
</asp:LinkButton>
<asp:LinkButton ID="LinkButtonLastPage" runat="server"
CommandArgument="Last"
CommandName="Page"
enabled="<%# ((GridView)Container.NamingContainer).PageIndex !=
((GridView)Container.NamingContainer).PageCount - 1 %>">>>
</asp:LinkButton>
</PagerTemplate>
</asp:GridView>
<asp:GridView ID="GridView1" runat="server"
DataSourceID="SqlDataSource1"
DataKeyNames="ID"
AllowPaging="true"
PageSize="10"
AutoGenerateColumns="true">
<PagerTemplate>
<asp:Label ID="LabelCurrentPage" runat="server"
Text="<%# ((GridView)Container.NamingContainer).PageIndex + 1 %>">
</asp:Label>/
<asp:Label ID="LabelPageCount" runat="server"
Text="<%# ((GridView)Container.NamingContainer).PageCount %>">
</asp:Label>
<asp:LinkButton ID="LinkButtonFirstPage" runat="server"
CommandArgument="First"
CommandName="Page"
enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0
%>"><<
asp:LinkButton ID="LinkButtonPreviousPage" runat="server"
CommandArgument="Prev" CommandName="Page"
enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>"><
</asp:LinkButton>
<asp:LinkButton ID="LinkButtonNextPage" runat="server"
CommandArgument="Next"
CommandName="Page"
enabled="<%# ((GridView)Container.NamingContainer).PageIndex !=
((GridView)Container.NamingContainer).PageCount - 1 %>">>
</asp:LinkButton>
<asp:LinkButton ID="LinkButtonLastPage" runat="server"
CommandArgument="Last"
CommandName="Page"
enabled="<%# ((GridView)Container.NamingContainer).PageIndex !=
((GridView)Container.NamingContainer).PageCount - 1 %>">>>
</asp:LinkButton>
</PagerTemplate>
</asp:GridView>
相关文章推荐
- gridview控件自定义绑定,响应模板列按钮事件
- VS2005 GridView动态绑定数据源(交叉表) 动态绑定列 动态生成模板列 自定义表头
- VS2005 GridView动态绑定数据源(交叉表) 动态绑定列 动态生成模板列 自定义表头
- GridView使用技巧之:如何在RowCommand里获取模板列里绑定的内容?
- -将DropDownList控件绑定 到GridView控当中,并调用方法给DropDownList控件在页面进行数据绑定
- GridView 模板列中的数据绑定
- 在aspx页动态加载ascx页面内容,给GridView控件绑定数据
- 自定义GridView分页模板中页码Button的实现
- GridView 动态添加绑定列和模板列
- ASP.NET—001:GridView绑定List、页面返回值
- wordpress自定义页面、模板
- gridview模板页面调用js函数
- GridView自定义模板编辑 更新 取消 删除
- List作为GridView数据源时,绑定模板列的例子
- WordPress:自定义页面模板
- Android布局设计之ExpandableList绑定XML数据构成级联、item布局页面的控件查找及配置child事件,自定义适配显示内容
- Azure PowerShell (11) 使用自定义虚拟机镜像模板,创建Azure虚拟机并绑定公网IP(VIP)和内网IP(DIP)
- 自定义GridView分页模板
- 对《自定义GridView分页模板中页码Button的实现》中程序的改进,追加显示空行功能
- gridview 模板里绑定多个参数