本人也是刚刚开始开发ASPWAP版也曾经困惑于分页。看现在的分页千篇一律
代码完全一致量多质量不行。现将自己总结的代码发布如下,希望会给你带去点帮助如果 有用就帮忙顶下
int countTotal = sumCount; //总记录数
int totalPage = 0; //总页数
if (countTotal % perPage == 0)
totalPage = Convert.ToInt16(countTotal / perPage);
else
totalPage = Convert.ToInt16(countTotal / perPage) + 1;
if (Request["page_c"] != "" && Request["page_c"] != null)
cur_page = Convert.ToInt16(Request["page_c"]);
int cp_n, cp_p; //上一页,下一页
if (cur_page > 1)
cp_p = cur_page - 1;
else
cp_p = 1;
if (cur_page < totalPage)
cp_n = cur_page + 1;
else
cp_n = totalPage;
link_p.NavigateUrl = "UserMain.aspx?page_c=" + cp_p;
link_n.NavigateUrl = "UserMain.aspx?page_c=" + cp_n;
sSql = " select top " + perPage + " * from b_bless where u_id =" + Session["u_id"] + " and id not in (select top " + perPage * cur_page + " id from b_bless)";
ds = sql.serUser(sSql);
dt = ds.Tables[0];
StringBuilder sb = new StringBuilder();
sb.Append("<table>");
for (int i = 0; i < dt.Rows.Count; i++)
{
sb.Append("<tr><td>标题</td><td><a href=/"ss.aspx?id=");
sb.Append(dt.Rows[i]["id"].ToString());
sb.Append("/">");
sb.Append(dt.Rows[i]["title"].ToString());
sb.Append("</a></td></tr><tr><td>内容</td><td>");
sb.Append(dt.Rows[i]["con"].ToString());
sb.Append("</td></tr>");
//MobileListItem it = new MobileListItem(dt.Rows[i]["con"].ToString() + "...", dt.Rows[i]["id"].ToString());
//this.List1.Items.Add(it);
}
sb.Append("</table>");
List1.ItemsAsLinks = true;
List1.DataBind();
写的比较杂见谅如有需要请加273810907QQ非诚勿扰