国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

asp.net 分頁控件

2019-11-17 01:41:05
字體:
來源:轉載
供稿:網友

asp.net 分頁控件

前臺

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Pager.ascx.cs" Inherits="Controls_Core_Pager" %><style type="text/CSS">    .GridViewPagerStyle {        background-position: top;        background-repeat: repeat-x;        border-bottom: 1px solid #ABC7EC;        color: #15428B;        font-weight: bold;    }    .GridViewPagerStyle table {        margin: auto;        text-align: center;    }    .GridViewPagerStyle table td { border: 0px; }    .GridViewPagerStyle a {        color: #15428B;        padding: 0px 1px 0px 1px;        text-decoration: none;    }    .GridViewPagerStyle span {        color: red;        font-weight: bold;        padding: 0px 1px 0px 1px;        text-decoration: none;    }</style><script type="text/javascript" language="Javascript">    function checkGo() {        var txtGoObj = document.getElementById(document.getElementById('hidTextBoxGoClientID').value);        if (txtGoObj && txtGoObj.value == '') {            txtGoObj.focus();            return false;        }        return true;    }</script><center>    <div style="background-color: #BBD5EC; width: 100%;">        <table class="GridViewPagerStyle" cellpadding="1" cellspacing="1" >            <tr align="center">                <td valign="middle" runat="server" id="tdAll" style="display: none;">                    <asp:LinkButton ID="imgAll" Text="顯示所有" runat="server" OnClick="All_Click" />|                </td>                <td valign="middle" runat="server" id="tdPageCount">                    共<asp:Label ID="lblPageCount" runat="server" Text="Label" Style="color: Red;"></asp:Label>頁/<asp:Label                                                                                                                    ID="lblRecordCount" runat="server" Text="Label" Style="color: Red;"></asp:Label>條記錄|                </td>                <td valign="middle" runat="server" id="tdCurrentIndex">                    當前第<asp:Label ID="lblCurrentPageIndex" runat="server" Text="Label" Style="color: Red;"></asp:Label>頁                </td>                <td valign="middle">                    <asp:LinkButton ID="imgFirstPage" runat="server" OnClick="imgFirstPage_Click" Text="首頁"></asp:LinkButton>                </td>                <td valign="middle">                    <asp:LinkButton ID="img

后臺:

public partial class Controls_Core_Pager : System.Web.UI.UserControl{    public delegate void GridViewDelegate();    #region Delegate    public event GridViewDelegate InitLoadData;    public event GridViewDelegate PageingLoadData;    public event GridViewDelegate BeforePageing;    public event GridViewDelegate AfterPageing;    private const string firstenabledimgurl = "~/Image/pager/first.gif";    private const string firstdisabledimgurl = "~/image/pager/first_disabled.gif";    private const string lastenabledimgurl = "~/image/pager/last.gif";    private const string lastdisabledimgurl = "~/image/pager/last_disabled.gif";    private const string prevenabledimgurl = "~/image/pager/prev.gif";    private const string prevdisabledimgurl = "~/image/pager/prev_disabled.gif";    private const string nextenabledimgurl = "~/image/pager/next.gif";    private const string nextdisabledimgurl = "~/image/pager/next_disabled.gif";    #endregion    public bool SimplePager    {        set        {            this.tdAll.Visible = !value;            this.tdCurrentIndex.Visible = !value;            this.tdImgGo.Visible = !value;            this.tdPageCount.Visible = !value;            this.tdTextGo.Visible = !value;        }    }    protected void Page_Load(object sender, EventArgs e)    {    }    public int RecordCount    {        get { return (ViewState["RecordCount"] != null) ? (int)ViewState["RecordCount"] : 0; }        set { ViewState["RecordCount"] = value; }    }    public int PageSize    {        get        {            if (string.IsNullOrEmpty(hidPageSize.Value) ||Convert.ToInt32( hidPageSize.Value)<=0)                hidPageSize.Value = "20";            return int.Parse(hidPageSize.Value);        }        set        {            hidPageSize.Value = value.ToString();        }    }    public int CurrentPageIndex    {        get { return (hidCurrentPageIndex.Value == string.Empty) ? 0 : int.Parse(hidCurrentPageIndex.Value); }        set { hidCurrentPageIndex.Value = value.ToString(); }    }    public void LoadData()    {        if (InitLoadData != null)        {            InitLoadData();            ShowStatus(0);        }    }    public void ReLoadData()    {        if (BeforePageing != null)        {            BeforePageing();        }        if (PageingLoadData != null)        {            PageingLoadData();            ShowStatus(CurrentPageIndex);        }        if (AfterPageing != null)        {            AfterPageing();        }    }    private void ShowStatus(int currentPageIndex)    {        int pageCount = Convert.ToInt32((RecordCount - 1) / PageSize + 1);        lblRecordCount.Text = RecordCount.ToString();        hidCurrentPageIndex.Value = currentPageIndex.ToString();        if (RecordCount == 0)        {            lblPageCount.Text = "0";            lblCurrentPageIndex.Text = "";        }        else        {            lblPageCount.Text = pageCount.ToString();            lblCurrentPageIndex.Text = Convert.ToString(currentPageIndex + 1);        }        if (pageCount == 0 || ((currentPageIndex + 1) == 1 && pageCount == 1))        {            imgFirstPage.Enabled = false;            imgPrePage.Enabled = false;            imgNextPage.Enabled = false;            imgLastPage.Enabled = false;        }        else        {            if (currentPageIndex == 0)            {                imgPrePage.Enabled = false;                imgFirstPage.Enabled = false;                imgNextPage.Enabled = true;                imgLastPage.Enabled = true;            }            else if ((currentPageIndex + 1) == pageCount)            {                imgFirstPage.Enabled = true;                imgPrePage.Enabled = true;                imgNextPage.Enabled = false;                imgLastPage.Enabled = false;            }            else if (currentPageIndex != 0 && (currentPageIndex + 1) != pageCount)            {                imgFirstPage.Enabled = true;                imgPrePage.Enabled = true;                imgNextPage.Enabled = true;                imgLastPag
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汉阴县| 商都县| 卫辉市| 莲花县| 井研县| 积石山| 曲阳县| 贵港市| 寿阳县| 股票| 卢氏县| 资中县| 札达县| 鄂尔多斯市| 崇义县| 保康县| 西林县| 莒南县| 桐城市| 海城市| 新竹市| 宜良县| 潍坊市| 冀州市| 兴仁县| 高阳县| 临城县| 舞阳县| 那坡县| 宣汉县| 米林县| 噶尔县| 昌乐县| 大石桥市| 德格县| 汤阴县| 辛集市| 无锡市| 杂多县| 长丰县| 高要市|