码迷,mamicode.com
首页 > Web开发 > 详细

如何使用 aspnetpager

时间:2014-07-16 23:38:11      阅读:371      评论:0      收藏:0      [点我收藏+]

标签:des   分页控件   style   blog   color   使用   

<%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>

  <webdiyer:AspNetPager id="AspNetPager1" runat="server" ShowPageIndexBox="Always" 
                                            PageSize="20" OnPageChanged="AspNetPager1_PageChanged" 
                                            TextBeforeInputBox="转到第  " 
              TextAfterInputBox="  页  " ShowPageIndex="False" 
                                            ShowInputBox="Always" 
              ShowCustomInfoSection="Left" PrevPageText="上一页" 
                                            NextPageText="下一页" LastPageText="尾页" 
              FirstPageText="首页" AlwaysShow="True" 
                                            CustomInfoSectionWidth="600" 
              CustomInfoTextAlign="NotSet" LayoutType="Table">
      </webdiyer:AspNetPager>


    
        <webdiyer:AspNetPager ID="AspNetPager2" runat="server" CloneFrom="AspNetPager1">
        </webdiyer:AspNetPager>

  

 public void checkCase()
        {
            string strSql = " ID>0";
            int num = bll.GetRecordCount(strSql);
            AspNetPager1.RecordCount = num;
            DataSet ds = bll.GetAspNetPagerDataSet(strSql, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize);
            if (ds.Tables[0].Rows.Count > 0)
            {
                this.Repeater1.DataSource = ds.Tables[0].DefaultView;
                this.Repeater1.DataBind();

                AspNetPager1.CustomInfoHTML = "共:<font color=\"red\"><b>" + AspNetPager1.RecordCount.ToString() + "</b></font>&nbsp;&nbsp;条记录";
                AspNetPager1.CustomInfoHTML += " 总页数:<font color=\"red\"><b>" + AspNetPager1.PageCount.ToString() + "</b></font>&nbsp;&nbsp;页";
                AspNetPager1.CustomInfoHTML += " 每页显示:<font color=\"red\"><b>" + AspNetPager1.PageSize.ToString() + "</b></font>&nbsp;条";
                AspNetPager1.CustomInfoHTML += " 当前页:<font color=\"red\"><b>" + AspNetPager1.CurrentPageIndex.ToString() + "</b></font>&nbsp;&nbsp;";
            }
        }

 bll 

/// <summary>
        /// 获得aspnetpager分页数据
        /// </summary>
        public DataSet GetAspNetPagerDataSet(string whereSql, int mypageindex, int mypagesize)
        {
            return dal.GetAspNetPagerList(whereSql, mypageindex, mypagesize);
        }

DAL

 /// <summary>
        /// 获得AspNetPager分页数据列表
        /// </summary>
        public DataSet GetAspNetPagerList(string strWhere, int mypageindex, int mypagesize)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(" SELECT ID,sTitle,sContent,sAuthor,sAuthorTel,sAuthorQQ,sAuthorEmail,toDepart,ifPass,PubDate ");
            strSql.Append(" FROM QuestionBook ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by ID desc");
            return SQLHelper.ExecuteWebDiyerDataset(SQLHelper.DBCONNECTIONSTRING, CommandType.Text, strSql.ToString(), mypageindex, mypagesize);
        }

DBTtility

 #region 为webdiyer分页控件做的 DataSet 传递参数进来 DataSet ExecuteWebDiyerDataset(string connString, CommandType cmdType, string cmdText,int mypageindex,int mypagesize, params SqlParameter[] cmdParms)
        public static DataSet ExecuteWebDiyerDataset(string connString, CommandType cmdType, string cmdText, int mypageindex, int mypagesize, params SqlParameter[] cmdParms)
        {
            SqlDataAdapter myAdapter = new SqlDataAdapter();
            myAdapter.SelectCommand = new SqlCommand();

            using (SqlConnection conn = new SqlConnection(connString))
            {
                PrepareCommand(myAdapter.SelectCommand, conn, null, cmdType, cmdText, cmdParms);
                DataSet ds = new DataSet();
                myAdapter.Fill(ds, mypagesize * (mypageindex - 1), mypagesize, "dtable");
                myAdapter.SelectCommand.Parameters.Clear();
                return ds;

            }

        }
        #endregion

如何使用 aspnetpager,布布扣,bubuko.com

如何使用 aspnetpager

标签:des   分页控件   style   blog   color   使用   

原文地址:http://www.cnblogs.com/tiger8000/p/3848700.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!