AspNetPager这个东西我也上在社区里面看到的!后来我下载来看看~结果一头雾水!所以在此请教各位有没有简单一点的代码呢~最好是功能实现出来的!嘻嘻!

解决方案 »

  1.   

    你下载的是dll文件吗?如果下载的是安装包的话里面应该包含了示例代码了呀.另外,你也可以去吴旗娃的网站上去看,他网站上面也有示例代码的.
      

  2.   

    我把这东西整理了一下
    C#代码
            protected void bindData()
            {
                DataTable dt = MyBFExample.InOut_Public_OldsterRecord_GetAll(AspNetPager1.StartRecordIndex, AspNetPager1.PageSize);
                //删除时应该从新计算所以不能IsPostBack
                AspNetPager1.RecordCount = Convert.ToInt32(dt.Rows[0]["RecordCount"]);
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }存储过程:
    ALTER PROCEDURE [dbo].[a_Example]
    @startIndex INT ,--每页的开始记录的索引
    @pageSize INT --每页记录数
    AS
    --取出记录总数 插入@RecordCountTable临时表
    declare @RecordCountTable table(RecordCount int)
    declare @RecordCount int
    set @RecordCount=(select count(InOutBedID) from InOut_InOut_InOutBed)
    insert into 
    @RecordCountTable
    (RecordCount)
    values
    (@RecordCount)
    begin
    --取出内容 每行左连记录总数 虚拟视图orderList
    WITH orderList AS 

    SELECT row_number() OVER (ORDER BY InOutBedID DESC)AS Row,*
    from InOut_InOut_InOutBed
    LEFT JOIN @RecordCountTable ON 1=1
    )
    --取出虚拟视图orderList中分页内容
    SELECT *
    FROM orderlist 
    WHERE row between @startIndex and @startIndex+@pageSize-1
      

  3.   

    http://www.webdiyer.com/AspNetPager/default.aspx
    看看这里吧!上面有演示,下载的!
      

  4.   

    我要的是AspNetPager+Repeater的例子~谁能告诉我里面的那个 存储过程怎么写啊
      protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int totalOrders = (int)SqlHelper.ExecuteScalar(CommandType.StoredProcedure, "P_GetOrderNumber");
                AspNetPager1.RecordCount = totalOrders;
                bindData();
            }
        }    void bindData()
        {
            Repeater1.DataSource = SqlHelper.ExecuteReader(CommandType.StoredProcedure, ConfigurationManager.AppSettings["pagedSPName"],
                new SqlParameter("@startIndex", AspNetPager1.StartRecordIndex),
                new SqlParameter("@pageSize", AspNetPager1.PageSize));
            Repeater1.DataBind();
        }    protected void AspNetPager1_PageChanged(object src, EventArgs e)
        {
            bindData();
        }
    这是例子代码
      

  5.   

    http://www.webdiyer.com/AspNetPager/default.aspx
    我怎么没有看见有演示啊
      

  6.   

    http://www.webdiyer.com/
    这里有很详细的说明啊
      

  7.   

    C#代码
            protected void bindData()
            {
                DataTable dt = MyBFExample.InOut_Public_OldsterRecord_GetAll(AspNetPager1.StartRecordIndex, AspNetPager1.PageSize);
                //删除时应该从新计算所以不能IsPostBack
                AspNetPager1.RecordCount = Convert.ToInt32(dt.Rows[0]["RecordCount"]);
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }            DataTable dt = MyBFExample.InOut_Public_OldsterRecord_GetAll(AspNetPager1.StartRecordIndex, AspNetPager1.PageSize);
    这个是是自己定义的一个返回DataTable 的方法 你可以自己写
      

  8.   

    select.aspx--------------------------------------------------------------------------------<%@ Page Language="C#" %>
    <%@ import Namespace="System.Data" %>
    <%@ import Namespace="System.Data.SqlClient" %>
    <script runat="server">    protected void Page_Load(Object sender, EventArgs e)
             {
                 int intPageNo,intPageSize,intPageCount;
                 intPageSize = 25;
                 if (Request["CurrentPage"]==null) 
                     {
                         intPageNo = 1;
                     }
                 else
                     {
                         intPageNo = Int32.Parse(Request["CurrentPage"]);
                     }
                 
                 
                 SqlConnection mySqlConnection = new SqlConnection("server=(local);Database=test;user id=sa;password=");
                 SqlCommand mySqlCommand = new SqlCommand("up_GetTopicList", mySqlConnection);
                 mySqlCommand.CommandType = CommandType.StoredProcedure;
                 
                 SqlParameter workParm;
                 
                 //搜索表字段,以","号分隔
                 workParm = mySqlCommand.Parameters.Add("@a_TableList", SqlDbType.VarChar, 200);
                 mySqlCommand.Parameters["@a_TableList"].Value = "OFFERID,type,offertime";
                 
                 //搜索表名
                 workParm = mySqlCommand.Parameters.Add("@a_TableName", SqlDbType.VarChar, 30);
                 mySqlCommand.Parameters["@a_TableName"].Value = "offer"; 
                 
                 //搜索条件,如"select * from aa where a=1 and b=2 and c=3"则条件为"where a=1 and b=2 and c=3"
                 workParm = mySqlCommand.Parameters.Add("@a_SelectWhere", SqlDbType.VarChar, 500);
                 mySqlCommand.Parameters["@a_SelectWhere"].Value = "where type='idl'"; 
                 
                 //表主键字段名,必须为INT类型
                 workParm = mySqlCommand.Parameters.Add("@a_SelectOrderId", SqlDbType.VarChar, 50);
                 mySqlCommand.Parameters["@a_SelectOrderId"].Value = "offerid";       
                 
                 //排序,可以使用多字段排序但主键字段必需在最前面
                 workParm = mySqlCommand.Parameters.Add("@a_SelectOrder", SqlDbType.VarChar, 50);
                 mySqlCommand.Parameters["@a_SelectOrder"].Value = "order by offerid desc"; 
                 
                 //页号
                 workParm = mySqlCommand.Parameters.Add("@a_intPageNo", SqlDbType.Int);
                 mySqlCommand.Parameters["@a_intPageNo"].Value = intPageNo; 
                 
                 //每页显示数
                 workParm = mySqlCommand.Parameters.Add("@a_intPageSize", SqlDbType.Int);
                 mySqlCommand.Parameters["@a_intPageSize"].Value = intPageSize; 
                 
                 //总记录数(存储过程输出参数)
                 workParm = mySqlCommand.Parameters.Add("@RecordCount", SqlDbType.Int);
                 workParm.Direction = ParameterDirection.Output;             
                 
                 //当前页记录数(存储过程返回值)
                 workParm = mySqlCommand.Parameters.Add("RowCount", SqlDbType.Int);
                 workParm.Direction = ParameterDirection.ReturnValue;             mySqlConnection.Open();
                 Repeater.DataSource = mySqlCommand.ExecuteReader();                                   
                 
                 Repeater.DataBind();
                 
                 mySqlConnection.Close();
                 
                 Int32 RecordCount = (Int32)mySqlCommand.Parameters["@RecordCount"].Value;
                 Int32 RowCount = (Int32)mySqlCommand.Parameters["RowCount"].Value;
                 
                 LabelRecord.Text = RecordCount.ToString();
                 LabelRow.Text = intPageNo.ToString();
                 intPageCount = RecordCount/intPageSize;
                 if ((RecordCount%intPageSize)>0)
                     intPageCount += 1;
                 LabelPage.Text = intPageCount.ToString();
                 
                 if (intPageNo>1)
                     {
                         HLFistPage.NavigateUrl = "select.aspx?CurrentPage=1";
                         HLPrevPage.NavigateUrl = String.Concat("select.aspx?CurrentPage=","",intPageNo-1);
                     }
                 else
                     {
                         HLFistPage.NavigateUrl = "";
                         HLPrevPage.NavigateUrl = "";
                         //HLFistPage.Enabled = false;
                         //HLPrevPage.Enabled = false;
                     }
                     
                 if (intPageNo<intPageCount)
                     {
                         HLNextPage.NavigateUrl = String.Concat("select.aspx?CurrentPage=","",intPageNo+1);
                         HLEndPage.NavigateUrl = String.Concat("select.aspx?CurrentPage=","",intPageCount);
                     }
                 else
                     {
                         HLNextPage.NavigateUrl = "";
                         HLEndPage.NavigateUrl = "";
                         //HLNextPage.Enabled=false;
                         //HLEndPage.Enabled=false;
                     }
                 
             }</script>
    <html>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <head>
        <link href="/style.CSS" rel="stylesheet" />
    <style type="text/css">
    .high {  font-family: "宋体"; font-size: 9pt; line-height: 140%}
    .mid {  font-size: 9pt; line-height: 12pt}
    .small {  font-size: 9pt; line-height: normal}
    .TP10_5 {
        font-size: 14px;
        line-height: 140%;
    }
    </style>
        <style type="text/css">A:link {
        COLOR: #cc6666
    }
    </style>
    </head>
    <body>
        <form runat="server">
    <span class="high">              第<font color="#CC0000"><asp:Label id="LabelRow" runat="server"/></font>页 | 共有<asp:Label id="LabelPage" runat="server"/>页 
                  | <asp:Label id="LabelRecord" runat="server"/>条信息 | 
                  <asp:HyperLink id="HLFistPage" Text="首页" runat="server"/> 
                  | <asp:HyperLink id="HLPrevPage" Text="上一页" runat="server"/>
                  | <asp:HyperLink id="HLNextPage" Text="下一页" runat="server"/>
                  | <asp:HyperLink id="HLEndPage" Text="尾页" runat="server"/></span><br>
        
            <asp:Repeater id=Repeater runat="server">            <HeaderTemplate>      <table width="583" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td bgcolor="#000000"><table width="100%" border="0" cellpadding="4" cellspacing="1" class="TP10_5">
                  <tr bgcolor="#999999"> 
                    <td align="center"> <strong><font color="#FFFFFF">订单号</font></strong></td>
                    <td align="center"> <strong><font color="#FFFFFF">服务项目</font></strong></td>
                    <td align="center"> <strong><font color="#FFFFFF">预订日期</font></strong></td>
                    <td align="center"> <strong><font color="#FFFFFF">操作人员</font></strong></td>
                    <td align="center"> <strong><font color="#FFFFFF">分配状态</font></strong></td>
                    <td> <div align="center"></div></td>
                  </tr>
                </HeaderTemplate>            <ItemTemplate>              <tr align="center" bgcolor="#FFFFFF" class="small" onMouseOver='this.style.background="#CCCCCC"' onMouseOut='this.style.background="#FFFFFF"'> 
                    <td><%# DataBinder.Eval(Container.DataItem, "offerid") %></td>
                    <td><%# DataBinder.Eval(Container.DataItem, "type") %></td>
                    <td><%# DataBinder.Eval(Container.DataItem, "offertime") %></td>
                    <td> </td>
                    <td> </td>
                    <td><a href="javascript:void(window.open('info.asp?id=<%# DataBinder.Eval(Container.DataItem, "offerid") %>','订单分配','height=600,width=1000'))">订单详情</a></td>
                  </tr>            </ItemTemplate>            <FooterTemplate>            </table></td>
            </tr>
          </table>            </FooterTemplate>        </asp:Repeater>    </form>
    </body>
    </html>
      

  9.   


    up_GetTopicList.sql--------------------------------------------------------------------------------CREATE proc up_GetTopicList 
           @a_TableList Varchar(200),
           @a_TableName Varchar(30), 
           @a_SelectWhere Varchar(500),
           @a_SelectOrderId Varchar(20),
           @a_SelectOrder Varchar(50),
           @a_intPageNo int,
           @a_intPageSize int,
           @RecordCount int OUTPUT
    as
       /*定义局部变量*/
       declare @intBeginID         int
       declare @intEndID           int
       declare @intRootRecordCount int
       declare @intRowCount        int
       declare @TmpSelect          NVarchar(600)
       /*关闭计数*/
       set nocount on
       
       /*求总共根贴数*/   select @TmpSelect = 'set nocount on;select @SPintRootRecordCount = count(*) from '+@a_TableName+' '+@a_SelectWhere
       execute sp_executesql 
                 @TmpSelect,
                 N'@SPintRootRecordCount int OUTPUT',
                 @SPintRootRecordCount=@intRootRecordCount OUTPUTselect @RecordCount = @intRootRecordCount   if (@intRootRecordCount = 0)    --如果没有贴子,则返回零
           return 0
           
       /*判断页数是否正确*/
       if (@a_intPageNo - 1) * @a_intPageSize > @intRootRecordCount
          return (-1)   /*求开始rootID*/
       set @intRowCount = (@a_intPageNo - 1) * @a_intPageSize + 1
       /*限制条数*/   select @TmpSelect = 'set nocount on;set rowcount @SPintRowCount;select @SPintBeginID = '+@a_SelectOrderId+' from '+@a_TableName+' '+@a_SelectWhere+' '+@a_SelectOrder
       execute sp_executesql 
                 @TmpSelect,
                 N'@SPintRowCount int,@SPintBeginID int OUTPUT',
                 @SPintRowCount=@intRowCount,@SPintBeginID=@intBeginID OUTPUT
       /*结束rootID*/
       set @intRowCount = @a_intPageNo * @a_intPageSize
       /*限制条数*/   select @TmpSelect = 'set nocount on;set rowcount @SPintRowCount;select @SPintEndID = '+@a_SelectOrderId+' from '+@a_TableName+' '+@a_SelectWhere+' '+@a_SelectOrder
       execute sp_executesql 
                 @TmpSelect,
                 N'@SPintRowCount int,@SPintEndID int OUTPUT',
                 @SPintRowCount=@intRowCount,@SPintEndID=@intEndID OUTPUT
    if @a_SelectWhere='' or @a_SelectWhere IS NULL
       select @TmpSelect = 'set nocount off;set rowcount 0;select '+@a_TableList+' from '+@a_TableName+' where '+@a_SelectOrderId+' between '
    else
       select @TmpSelect = 'set nocount off;set rowcount 0;select '+@a_TableList+' from '+@a_TableName+' '+@a_SelectWhere+' and '+@a_SelectOrderId+' between 'if @intEndID > @intBeginID
       select @TmpSelect = @TmpSelect+'@SPintBeginID and @SPintEndID'+' '+@a_SelectOrder
    else
       select @TmpSelect = @TmpSelect+'@SPintEndID and @SPintBeginID'+' '+@a_SelectOrder   execute sp_executesql 
                 @TmpSelect,
                 N'@SPintEndID int,@SPintBeginID int',
                 @SPintEndID=@intEndID,@SPintBeginID=@intBeginID   return(@@rowcount)
       --select @@rowcount
    GO
      

  10.   

    我第一次使用時寫的 //取得数据列表
        private void getDataSet()
        {
            BGetDat gd = new BGetDat(objconn);
            DataSet ds=gd.getUserSubmitFileList();
            AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;
            Session["usersumfileds"] = ds;
            databind(ds);
        }    private void databind(DataSet ds)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<table class='border' border='0' cellspacing='1' width='100%' cellpadding='0'>");
            sb.Append("<tr class='title' height='22'>");
            sb.Append("<td>编号</td><td>资料名称</td><td>类别</td><td>销售价格</td><td>销售类别</td><td>提交时期</td><td>提交会员</td><td>操作</td>");
            sb.Append("</tr>");
            int startindex = AspNetPager1.StartRecordIndex;
            while (startindex <= AspNetPager1.EndRecordIndex)
            {
                sb.Append("<tr class='tdbg' onmouseout=this.className='tdbg' onmouseover=this.className='tdbgmouseover'>");
                sb.Append("<td>" + ds.Tables[0].Rows[startindex-1]["SubmitFileID"].ToString() + "</td>");
                sb.Append("<td>" + ds.Tables[0].Rows[startindex-1]["FileName"].ToString() + "</td>");
                sb.Append("<td>" + ds.Tables[0].Rows[startindex-1]["ClassTypes"].ToString() + "</td>");
                sb.Append("<td>" + ds.Tables[0].Rows[startindex - 1]["SalePrice"].ToString() + "</td>");         
                switch (ds.Tables[0].Rows[startindex - 1]["DanWei"].ToString())
                {
                    case "0":
                        sb.Append("<td>现金</td>");
                        break;
                    case "1":
                        sb.Append("<td>快乐币</td>");
                        break;
                    case "2":
                        sb.Append("<td>免费</td>");
                        break;
                }
                sb.Append("<td>" + ds.Tables[0].Rows[startindex - 1]["SubmitDate"].ToString() + "</td>");
                sb.Append("<td>" + ds.Tables[0].Rows[startindex - 1]["UserID"].ToString() + "</td>");
                sb.Append("<td><a>审核</a> <a>删除</a></td>");
                sb.Append("</tr>");
                startindex++;
            }
            sb.Append("</table>");
            list.InnerHtml = sb.ToString();
        }
      

  11.   

    WTS分页三剑侠
    http://community.csdn.net/Expert/topic/5290/5290374.xml?temp=.4305994
      

  12.   

    我下了啊~就是例子里面的什么存储过程我找不到所以才看不懂的
    ====================>
    存储过程在示例项目的数据库中(App_Data文件夹中),你可以用vs2005的资源管理器连接上那个数据库,打开就可以看到所有的数据以及存储过程等
      

  13.   

    看看这里
    http://community.csdn.net/Expert/topic/5313/5313744.xml?temp=.5531275
    比ASPNETPAGER简单简多了