zoukankan      html  css  js  c++  java
  • GRIDVIEW分页用户控件

    前台:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Pager.ascx.cs" Inherits="e_booking_English_UserControls_Pager" %>
    <div style="text-align: right; padding-right: 30px">
        每页<asp:Label ID="pagesize" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageSize %>'
            Style="padding-right: 3px; padding-left: 3px"></asp:Label>项 共<asp:Label ID="rowscount"
                runat="server" Text='<%# ((GridView)Container.Parent.Parent).Rows.Count %>' Style="padding-right: 3px;
                padding-left: 3px"></asp:Label>项
        <asp:LinkButton ID="cmdFirstPage" runat="server" CommandName="Page" CommandArgument="First"
            Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=0 %>">首页</asp:LinkButton>
        <asp:LinkButton ID="cmdPreview" runat="server" CommandArgument="Prev" CommandName="Page"
            Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=0 %>">前页</asp:LinkButton>
        第<asp:Label ID="lblcurPage" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex+1%>'
            Style="padding-right: 3px; padding-left: 3px"></asp:Label>页/共<asp:Label ID="lblPageCount"
                runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageCount %>' Style="padding-right: 3px;
                padding-left: 3px"></asp:Label>页
        <asp:LinkButton ID="cmdNext" runat="server" CommandName="Page" CommandArgument="Next"
            Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=((GridView)Container.Parent.Parent).PageCount-1 %>">后页</asp:LinkButton>
        <asp:LinkButton ID="cmdLastPage" runat="server" CommandArgument="Last" CommandName="Page"
            Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=((GridView)Container.Parent.Parent).PageCount-1 %>">尾页</asp:LinkButton>
        转到<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" CausesValidation="false"
            OnSelectedIndexChanged="DropPageChanged" OnDataBinding="DropDownList1_DataBinding">
        </asp:DropDownList>
        页
    </div>

    后台:

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class e_booking_English_UserControls_Pager : System.Web.UI.UserControl
    {
        public GridView grd
        {
            get
            {
                GridView grd = Parent.Parent.NamingContainer as GridView;
                return grd;
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {

        }
        protected void DropPageChanged(object sender, EventArgs e)
        {
            DropDownList DropDownList1 = sender as DropDownList;
            grd.PageIndex = int.Parse(DropDownList1.SelectedValue);
        }
        protected void DropDownList1_DataBinding(object sender, EventArgs e)
        {
            for (int i = 1; i <= grd.PageCount; i++)
            {
                DropDownList1.Items.Add(new ListItem(i + "/" + grd.PageCount, (i - 1).ToString()));
            }
            DropDownList1.SelectedIndex = grd.PageIndex;
        }
    }

  • 相关阅读:
    Hibernate映射之数组属性, 集合属性(list、set和map)
    org.hibernate.type.SerializationException: could not deserialize 反序列化失败
    linux下同一个tomcat部署多个项目
    Nexus私服 Maven
    maven 父子项目 聚合与继承 生命周期 打包插件 依赖打包 jar pom war
    IDEA中创建Web聚合项目(Maven多模块项目)
    为什么要在linux命令前加上 ./ 什么时候才需要在命令前加上./
    web.xml 介绍 and pom.xml 介绍
    有趣的linux命令
    SpringMVC 中常见注释
  • 原文地址:https://www.cnblogs.com/cosiray/p/1551968.html
Copyright © 2011-2022 走看看