日期:2014-05-17  浏览次数:20427 次

aspnetpager 控件显示分页问题
前台:
<webdiyer:aspnetpager id="AspNetPager1" runat="server" horizontalalign="Center" 
  onpagechanged="AspNetPager1_PageChanged" UrlPaging="True" FirstPageText="首页" 
  LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" CustomInfoStyle="" 
  EnableUrlRewriting="True" UrlPageIndexName="page" UrlRewritePattern="" 
  CustomInfoSectionWidth="30%" PageIndexBoxType="DropDownList" 
  ShowBoxThreshold="2" ShowCustomInfoSection="Left" Width="660px" 
  TextAfterPageIndexBox=" 页" TextBeforePageIndexBox="跳转至:" AlwaysShow="True" 
  PageSize="2" >
</webdiyer:aspnetpager>

C#:
  ds = new BLL.blogtext().getList(blogid,AspNetPager1.PageSize *(AspNetPager1.CurrentPageIndex - 1),AspNetPager1.PageSize ,"temp1");///这个方法在下面

  DataList1.DataSource = ds.Tables["temp1"] ;
  AspNetPager1.PageSize = 1; //设置每页显示的记录条数
  AspNetPager1.RecordCount = ds.Tables["temp1"].Rows.Count; //得出总的记录条数

  DataList1.DataBind(); ;//绑定的数据

  AspNetPager1.CustomInfoHTML = " 共 " + AspNetPager1.RecordCount.ToString() + " 篇文章 //显示记录条数
  AspNetPager1.CustomInfoHTML += " 当前 <font color=\"red\">" + AspNetPager1.CurrentPageIndex.ToString() + "</font>/" + AspNetPager1.PageCount.ToString() + " 页";//显示当前页/共多少页

DAL:

 public DataSet getList(int blogid, int startRecord, int maxRecord, string tableName)
  {
  string sqltxt = @"select * from blogtext where BlogID=@bi order by Time desc";
  SqlConnection cone = new SqlConnection(Dbconnect);
  SqlCommand cmd = new SqlCommand(sqltxt, cone);
  cmd.Parameters.Add("@bi", SqlDbType.Int, 4);
  cmd.Parameters["@bi"].Value = blogid;
  SqlDataAdapter da = new SqlDataAdapter(cmd);

  DataSet ds = new DataSet();
  try
  {
  cone.Open();
  da.Fill(ds, startRecord, maxRecord, tableName);
   
  }
  catch
  {
  throw;
  }
  finally
  {
  cone.Close();

  }
  return ds;
  }

=========================================================
问题是:无论我怎么调那个pagesize的值,都只显示一页的数据,而且总页数只有一页,诚心求教!

------解决方案--------------------
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" CustomInfoSectionWidth="80%"
FirstPageText='首页' InputBoxClass="pagerinput"
LastPageText='尾页' NextPageText='下一页'
OnPageChanging="AspNetPager1_PageChanging" PageSize="2" PrevPageText='上一页'
ShowCustomInfoSection="Left" ShowInputBox="Always" ShowNavigationToolTip="False"
SubmitButtonClass="pagerbtn" SubmitButtonStyle="height:20"
SubmitButtonTe