using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SqlHelp;
using System.Data;
public partial class ajax : System.Web.UI.Page
{
int currentpage = 0;
int dispnum = 5;
int countpage = 1;
int control = 0;
protected void Page_Load(object sender, EventArgs e)
{
string str = Request["current"].ToString();
currentpage = Convert.ToInt32(Request["current"].ToString());//获取当前的页数
control = Convert.ToInt32(Request["control"].ToString());
//我还要获取它的操作数
//获取总数
int cnums = OperSql.GetReCount();//总记录数
if (cnums % dispnum == 0)
{
countpage = cnums / dispnum; //总页数
}
else
{
countpage = cnums / dispnum + 1; //总页数
}
if (control == 1)
{
page(countpage, 1,dispnum);
//首页了后,我们还要控制,
}
if (control == 2)
{
page(countpage, currentpage+1,dispnum);
}
if (control == 3)
{
page(countpage, currentpage - 1, dispnum);
}
if(control==4)
{
page(countpage, countpage, dispnum);
}
//然后我们获取到内容,然后做拼接
// 我的分页是
}
void page(int countpage,int currentpage,int dispnum)
{
if (currentpage > 1 && currentpage < countpage)
{
DataSet ds = OperSql.GetPage((currentpage - 1) * 5, dispnum);//当前的显示数,和下一页的显示数
Response.Write("<table>");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Response.Write("<tr>");
Response.Write("<td>");
Response.Write(ds.Tables[0].Rows[i]["newstitle"].ToString());
Response.Write("</td>");
Response.Write("</tr>");
}
Response.Write("</table>");
Response.Write("<div id='controlsid'style=' width:auto;background-color:blue'>");
Response.Write("<ul>");
Response.Write("<li id='first'>");
Response.Write("<a + "1" + ")'>" + "首页" + "</a>");
Response.Write("</li>");
Response.Write("<li id='nextpage'>");
Response.Write("<a + "2" + ")'>" + "下一页" + "</a>");
Response.Write("</li>");
Response.Write("<li id='gopage'>");
Response.Write("<a + "3" + ")'>" + "上一页" + "</a>");
Response.Write("</li>");
Response.Write("<li id='lastpage'>");
Response.Write("<a + "4" + ")'>" + "尾页" + "</a>");
Response.Write("</li>");
Response.Write("<li>");
Response.Write("共" + countpage.ToString() + "页");
Response.Write("</li>");
Response.Write("<li>" + "当前在");
Response.Write("</li>");
Response.Write("<li id='cuentindex'>");
Response.Write(currentpage.ToString());
Response.Write("</li>");
Response.Write("<li>" + "页");
Response.Write("</li>");
Response.Write("</ul>");
Response.Write("</div>");
}
if (currentpage == 1)
{
DataSet ds = OperSql.GetPage((currentpage - 1) * 5, dispnum);//当前的显示数,和下一页的显示数
Response.Write("<table>");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Response.Write("<tr>");
Response.Write("<td>");
Response.Write(ds.Tables[0].Rows[i]["newstitle"].ToString());
Response.Write("</td>");
Response.Write("</tr>");
}
Response.Write("</table>");
Response.Write("<div id='controlsid' style='width:auto;background-color:blue' >");
Response.Write("<ul>");
//Response.Write("<li id='first'>");
//Response.Write("<a + "1" + ")'>" + "首页" + "</a>");
//Response.Write("</li>");
Response.Write("<li id='nextpage'>");
Response.Write("<a + "2" + ")'>" + "下一页" + "</a>");
Response.Write("</li>");
//Response.Write("<li id='gopage'>");
//Response.Write("<a + "3" + ")'>" + "上一页" + "</a>");
//Response.Write("</li>");
Response.Write("<li id='lastpage'>");
Response.Write("<a + "4" + ")'>" + "尾页" + "</a>");
Response.Write("</li>");
Response.Write("<li>");
Response.Write("共" + countpage.ToString() + "页");
Response.Write("</li>");
Response.Write("<li>"+"当前在");
Response.Write("</li>");
Response.Write("<li id='cuentindex'>");
Response.Write(currentpage);
Response.Write("</li>");
Response.Write("<li>" + "页");
Response.Write("</li>");
Response.Write("</ul>");
Response.Write("</div>");
}
if (currentpage == countpage)
{
DataSet ds = OperSql.GetPage((currentpage - 1) * 5, dispnum);//当前的显示数,和下一页的显示数
Response.Write("<table>");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
Response.Write("<tr>");
Response.Write("<td>");
Response.Write(ds.Tables[0].Rows[i]["newstitle"].ToString());
Response.Write("</td>");
Response.Write("</tr>");
}
Response.Write("</table>");
Response.Write("<div id='controlsid' style='width:auto;' >");
Response.Write("<ul style='width:650px'>");
Response.Write("<li id='first'>");
Response.Write("<a + "1" + ")'>" + "首页" + "</a>");
Response.Write("</li>");
//Response.Write("<li id='nextpage'>");
//Response.Write("<a + "2" + ")'>" + "下一页" + "</a>");
//Response.Write("</li>");
Response.Write("<li id='gopage'>");
Response.Write("<a + "3" + ")'>" + "上一页" + "</a>");
Response.Write("</li>");
Response.Write("<li>");
Response.Write("共" + countpage.ToString() + "页");
Response.Write("</li>");
Response.Write("<li>" + "当前在");
Response.Write("</li>");
Response.Write("<li id='cuentindex'>");
Response.Write( currentpage);
Response.Write("</li>");
Response.Write("<li>" + "页");
Response.Write("</li>");
Response.Write("</ul>");
Response.Write("</div>");
}
}
}