zoukankan      html  css  js  c++  java
  • ASP.NET练习③——AspNetChosmePager

    aspx代码:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="_ChosmePager.aspx.cs" Inherits="AspNetChosmePager._ChosmePager" %>
    <%@ Register Assembly="Reasee.Controls" Namespace="Reasee.Controls.ChosmePager" TagPrefix="cc1" %>
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div id="content">
            <asp:ListView ID="lvPC" runat="server">
                <LayoutTemplate>
                    <table id="table1">
                       <thead>
                           <tr>
                               <th>PCNum</th>
                               <th>NetIP</th>
                           </tr>
                       </thead>
                        <tbody>
                            <asp:PlaceHolder ID="itemPlaceHolder" runat="server"></asp:PlaceHolder>
                        </tbody>
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr>
                        <td><%# Eval("PCNum") %></td>
                        <td><%# Eval("NetIP") %></td>
                    </tr>
                </ItemTemplate>
            </asp:ListView>
        </div>
        <div id="pager">
            <cc1:ChosmePager runat="server" ID="cPager" AlwaysShow="true" PageSize="6" FirstPageText="首页" LastPageText="尾页" NextPageText=">>" PrevPageText="<<" OnPageChanged="cPager_PageChanged" ShowCustomInfoSection="Left" >
    
            </cc1:ChosmePager>
        </div>
        </form>
    </body>
    </html>
    

      

    cs代码:

            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    LvDataBind();
                }
            }
    
            private void LvDataBind()
            {
                int pageIndex = cPager.CurrentPageIndex - 1;    //索引从1开始
                int pageSize = cPager.PageSize;
                DataTable dt = new _PCManager().GetListByPage(pageSize, pageIndex).Tables[0];
                lvPC.DataSource = dt;
                lvPC.DataBind();
                cPager.RecordCount = new _PCManager().GetTotalCount();
                cPager.CustomInfoText = "记录总数:<font color=\"blue\"><b>" + cPager.RecordCount.ToString() + "</b></font>";
                cPager.CustomInfoText += " 总页数:<font color=\"blue\"><b>" + cPager.PageCount.ToString() + "</b></font>";
                cPager.CustomInfoText += " 当前页:<font color=\"red\"><b>" + cPager.CurrentPageIndex.ToString() + "</b></font>";
            }
    
            protected void cPager_PageChanged(object src, Reasee.Controls.ChosmePager.PageChangedEventArgs e)
            {
                cPager.CurrentPageIndex = e.NewPageIndex;
                LvDataBind();
            }
        }
    

      SQL:

    ALTER proc [dbo].[GetPCInfoByPage]
    @pageSize int,
    @pageIndex int
    as
     
    declare @pageCountStart int
    set @pageCountStart = @pageSize * @pageIndex
     
    declare @pageCountEnd int
    set @pageCountEnd = @pageSize * (@pageIndex + 1)
     
    select * from (
        select ROW_NUMBER() over (order by ID asc) row,*
        from PCInfo
    )t
    where t.row>@pageCountStart and t.row<=@pageCountEnd
    

      

    http://pan.baidu.com/s/1c1UDzNU

  • 相关阅读:
    国外高手又一力作,CAML Builder
    用word2007发布blog!!
    SharePoint Server 2007 trial 年末大餐细细品尝 (第八口)
    SharePoint Server 2007 trial 年末大餐细细品尝 (再来一口)
    SharePoint Server 2007 trial 年末大餐细细品尝 (第三口)
    SharePoint Server 2007 trial 年末大餐细细品尝 (第十口)
    卡壳了~~~
    SharePoint Server 2007 trial 年末大餐细细品尝 (第九口)
    moss 与 ad 用户信息不同步的问题。
    SharePoint Server 2007 trial 年末大餐细细品尝 (第六口)
  • 原文地址:https://www.cnblogs.com/xiaoli9627/p/6348028.html
Copyright © 2011-2022 走看看