求助!ASP.NET怎么实现分页?
求助大神!ASP.NET怎么实现分页?
具体:从数据库调出来的数据要求分页呈现。每10条一页。(不想用控件,控件的美观很难调整)
数据表为comments,表内字段为id,text,time,name.
谢谢!
[解决办法]
sql语句分页绑定啊,不过也得勇哥控件显示几页的吧!!
[解决办法]
可以使用aspnetpager分页控件。
http://www.webdiyer.com/downloads/
http://blog.csdn.net/chinacsharper/article/details/9095387
[解决办法]
<webdiyer:AspNetPager ID="anp" runat="server" AlwaysShow="True" CustomInfoHTML="总共%RecordCount%条记录,第%CurrentPageIndex%页/共%PageCount%页"
FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" OnPageChanged="anp_PageChanged"
PageSize="15" PrevPageText="上一页" ShowCustomInfoSection="Left" ShowMoreButtons="False"
ShowPageIndex="False" ShowPageIndexBox="Always" SubmitButtonText="GO" TextAfterPageIndexBox="页" SubmitButtonClass="ttn"
TextBeforePageIndexBox="转到第" PageIndexBoxClass="inpu">
</webdiyer:AspNetPager>
开头添加:<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
[解决办法]
int PagSize = 10;
if (Request.Form["rows"] != null)
PagSize = Convert.ToInt32(Request.Form["rows"]);
int PagIndex = 1;
if (Request.Form["page"] != null)
PagIndex = Convert.ToInt32(Request.Form["page"]);
int RowCount = -1;
if (Request.Form["rowcount"] != null)
RowCount = Convert.ToInt32(Request["rowcount"]);
string orderstr = "";
if (Request.Form["sort"] != null)
orderstr = Request.Form["sort"] + " " + Request.Form["order"];
else
orderstr = "要排序字段 desc";
string WhereStr = "1=1";
List<SqlParameter> PList = new List<SqlParameter>();
PList.Add(new sqlparameter(自己加参数))
string SQLCount="sql语句"
string SQLData="sql语句"
[解决办法]
用AspNetPager分页http://www.webdiyer.com/downloads/
然后在加上http://www.cnblogs.com/zengxiangzhan/archive/2010/03/03/1677460.html 这个样式就可以了,
http://blog.csdn.net/zhudiwoaini/article/details/7282984
[解决办法]
自己控制游标 每次取出固定的数据, 如20行, 逐步填充到 table
Dim dt As Data.DataSet = New Data.DataSet
'声明DataSet对象,并实例话
mycmd.Fill(dt, viewstate("startpage") * viewstate("PageSize"), viewstate("PageSize"), "infor")
[解决办法]