js翻页,已转成c#的
2015-11-12 10:35
393 查看
string page = "";
page = Request.QueryString["page"];
if (string.IsNullOrEmpty(page))
{
page = "1";
}
DataTable rst0 = null;
if (page == "1")
{
rst0 = DAL.SQLiteHelper.ExecuteDataTable(DAL.SQLiteHelper.CONN_STRING, CommandType.Text, sqlt);
Session["dvlistt"] = rst0;
}
if (Session["dvlistt"] == null)
{
rst0 = DAL.SQLiteHelper.ExecuteDataTable(DAL.SQLiteHelper.CONN_STRING, CommandType.Text, sqlt);
Session["dvlistt"] = rst0;
}
else
{
rst0 = (DataTable)Session["dvlistt"];
}
int zolpage = 0, curend = 0, fys = 12;
zolpage = rst0.Rows.Count;
if ((int.Parse(page) - 1) + fys < zolpage)
{
curend = (int.Parse(page) - fys) + 1;
}
else
{
curend = zolpage;
}
for (int i = int.Parse(page) - 1; i < curend; i++)
{
sb.AppendLine("<li> <a href=\"product_title_" + rst0.Rows[i]["id"] + ".aspx\"><img src=\"" + rst0.Rows[i]["img1"] + "\" width=\"120\" height=\"125\" /></a>");
sb.AppendLine("<h2><a href=\"product_title_" + rst0.Rows[i]["id"] + ".aspx\" title=\"" + rst0.Rows[i]["title"] + "\">" + rst0.Rows[i]["title"] + "</a></h2>");
sb.AppendLine("</li>");
}
-----------------------上面是展示列表
sb.AppendLine(GetPageBar(int.Parse(page), zolpage,""));
---------------------调用翻页-------------
-------------------------------翻页函数,需
private string GetPageBar(int currentPageIndex, int pageCount, string others)
{
string strHtml = "";
int endPage = 0;
int prevpage = currentPageIndex - 1, nextpage = currentPageIndex + 1;
strHtml += "<div class=\"xfenye s_12bh\">";
if (prevpage < 1)
{
strHtml += "<a href=\"#\">首页</a>";
strHtml += "<a href=\"#\">前页</a>";
}
else
{
strHtml += "<a href=\"" + others + "\\page-1\">首页</a>";
strHtml += "<a href=\"" + others + "\\page-" + prevpage + "\">前页</a>";
}
if (currentPageIndex != 1)
strHtml += "<a href=\"" + others + "\\page-1\">1</a>";
if (currentPageIndex >= 5)
strHtml += "<a>……</a>";
if (pageCount > currentPageIndex + 4)
{
endPage = currentPageIndex + 4;
}
else
{
endPage = pageCount;
}
for (int i = currentPageIndex - 2; i <= endPage; i++)
{
if (i > 0)
{
if (i == currentPageIndex)
{
strHtml += "<a href=\"#\" style=\"color:#F00\">" + i.ToString() + "</a>";
}
else
{
4000
if (i != 1 && i != pageCount)
{
strHtml += "<a href=\"" + others + "\\page-" + i.ToString() + "\">" + i.ToString() + "</a>";
}
}
}
}
if (currentPageIndex + 5 < pageCount) strHtml += "<a>……</a>";
if (currentPageIndex != pageCount) strHtml += "<a href=\"" + others + "\\page-" + pageCount.ToString() + "\">" + pageCount.ToString() + "</a>";
if (nextpage > pageCount)
{
strHtml += "<a href=\"#\">后页</a>";
strHtml += "<a href=\"#\">尾页</a>";
}
else
{
strHtml += "<a href=\"" + others + "\\page-" + nextpage + "\">后页</a>";
strHtml += "<a href=\"" + others + "\\page-" + pageCount + "\">尾页</a>";
}
strHtml += "</div>";
return strHtml;
}
page = Request.QueryString["page"];
if (string.IsNullOrEmpty(page))
{
page = "1";
}
DataTable rst0 = null;
if (page == "1")
{
rst0 = DAL.SQLiteHelper.ExecuteDataTable(DAL.SQLiteHelper.CONN_STRING, CommandType.Text, sqlt);
Session["dvlistt"] = rst0;
}
if (Session["dvlistt"] == null)
{
rst0 = DAL.SQLiteHelper.ExecuteDataTable(DAL.SQLiteHelper.CONN_STRING, CommandType.Text, sqlt);
Session["dvlistt"] = rst0;
}
else
{
rst0 = (DataTable)Session["dvlistt"];
}
int zolpage = 0, curend = 0, fys = 12;
zolpage = rst0.Rows.Count;
if ((int.Parse(page) - 1) + fys < zolpage)
{
curend = (int.Parse(page) - fys) + 1;
}
else
{
curend = zolpage;
}
for (int i = int.Parse(page) - 1; i < curend; i++)
{
sb.AppendLine("<li> <a href=\"product_title_" + rst0.Rows[i]["id"] + ".aspx\"><img src=\"" + rst0.Rows[i]["img1"] + "\" width=\"120\" height=\"125\" /></a>");
sb.AppendLine("<h2><a href=\"product_title_" + rst0.Rows[i]["id"] + ".aspx\" title=\"" + rst0.Rows[i]["title"] + "\">" + rst0.Rows[i]["title"] + "</a></h2>");
sb.AppendLine("</li>");
}
-----------------------上面是展示列表
sb.AppendLine(GetPageBar(int.Parse(page), zolpage,""));
---------------------调用翻页-------------
-------------------------------翻页函数,需
private string GetPageBar(int currentPageIndex, int pageCount, string others)
{
string strHtml = "";
int endPage = 0;
int prevpage = currentPageIndex - 1, nextpage = currentPageIndex + 1;
strHtml += "<div class=\"xfenye s_12bh\">";
if (prevpage < 1)
{
strHtml += "<a href=\"#\">首页</a>";
strHtml += "<a href=\"#\">前页</a>";
}
else
{
strHtml += "<a href=\"" + others + "\\page-1\">首页</a>";
strHtml += "<a href=\"" + others + "\\page-" + prevpage + "\">前页</a>";
}
if (currentPageIndex != 1)
strHtml += "<a href=\"" + others + "\\page-1\">1</a>";
if (currentPageIndex >= 5)
strHtml += "<a>……</a>";
if (pageCount > currentPageIndex + 4)
{
endPage = currentPageIndex + 4;
}
else
{
endPage = pageCount;
}
for (int i = currentPageIndex - 2; i <= endPage; i++)
{
if (i > 0)
{
if (i == currentPageIndex)
{
strHtml += "<a href=\"#\" style=\"color:#F00\">" + i.ToString() + "</a>";
}
else
{
4000
if (i != 1 && i != pageCount)
{
strHtml += "<a href=\"" + others + "\\page-" + i.ToString() + "\">" + i.ToString() + "</a>";
}
}
}
}
if (currentPageIndex + 5 < pageCount) strHtml += "<a>……</a>";
if (currentPageIndex != pageCount) strHtml += "<a href=\"" + others + "\\page-" + pageCount.ToString() + "\">" + pageCount.ToString() + "</a>";
if (nextpage > pageCount)
{
strHtml += "<a href=\"#\">后页</a>";
strHtml += "<a href=\"#\">尾页</a>";
}
else
{
strHtml += "<a href=\"" + others + "\\page-" + nextpage + "\">后页</a>";
strHtml += "<a href=\"" + others + "\\page-" + pageCount + "\">尾页</a>";
}
strHtml += "</div>";
return strHtml;
}
相关文章推荐
- js翻页,待转成c#的
- js中的特有语句with和 for in
- 利用Notepad++插件(JSToolNpp):让JS代码格式化对齐
- Javascript实现页面跳转的几种方式
- DataContractJsonSerializer和JavaScriptSerializer内部实现差异
- JSTL:c:forEach使用
- javascript伸缩菜单栏实现代码分享
- JSP自定义标签开发入门
- 关于JS和OC交互
- javascript发送短信验证码实现代码
- 12种JavaScript MVC框架之比较
- javascript倒计时效果实现
- HTML TBLE表格重复内容列合并javascript方法
- 编译webrtc到pjsip中的方法
- js confirm()方法的使用方法实例
- javascript手风琴下拉菜单实现代码
- Array运用
- javascript深入理解js闭包
- JavaScript中的运算操作陷阱
- javascript弹出窗口实现代码