asp自带有很多的控件自带分页功能,但是用过之后就会发现,当写较为复杂的SQL语句时明显就跟不上了,还有就是那个界面真心丑,有时候不得不自己动手重新写一套css样式表出来,明显感觉舒爽多了,既然自己写了表格 的css那分页功能就也得自己动手了,这是我前几日自己写东西时的语句,当然这只是一个比较初级的:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Text;
public partial class showldxx : System.Web.UI.Page
{
private int totalCount = 0;//总记录数目
private int PageSize = 4; //每页显示数据条目
private int pagecount = 0;//总页数
private int nowpage = 1;//当前页数
protected void Page_Load(object sender, EventArgs e)
{
ShowDjyd(dbstring());
showFoot();
}
protected string dbstring()
{
zgfjm.Class1 gfjm = new zgfjm.Class1();
string[] cfg = new string[12];
operateDefaultFile mop = new operateDefaultFile();
cfg = mop.getCourseConfig(Server.MapPath("./") + "App_Data\\config.xml");
string lxdh = cfg[2];
ViewState["kcm"] = cfg[0];
ViewState["tcnm"] = cfg[1];
string mulu = Server.MapPath("App_Data/") + gfjm.Encrypt("dbfile", lxdh.Substring(3, 8)) + "\\" + gfjm.Encrypt("netcourse", lxdh.Substring(3, 8)) + "\\";
string db = mulu + "sss.mdb";
return db;
}
private void ShowDjyd(String db)
{//显示右侧所有的新闻
HttpCookie mycookie = Request.Cookies["guest"];
string sql = "";
courseAccessDatabaseOperator.MDBOperator.operateMDB accessdbcn = new courseAccessDatabaseOperator.MDBOperator.operateMDB(db);
OleDbDataReader myrd;
if (Request.QueryString["nowpage"] == null||Convert.ToInt32(Request.QueryString["nowpage"