private int firtv;
private int lastv;
这些需要纪录的变量要设置成static的
private static int firtv;
private static int lastv;
这样值才会在刷新叶面时保留下来
private int lastv;
这些需要纪录的变量要设置成static的
private static int firtv;
private static int lastv;
这样值才会在刷新叶面时保留下来
解决方案 »
- asp.net 按钮变灰的问题
- C# Receive 您的主机中的软件放弃了一个已建立的连接
- WPF和webBrower做无边框浏览器?
- 在smartphone中有没有类似button的控件
- 高分求教 C#连接Oracle,如何不安装客户端,该怎么解决,又没有解决办法
- 求职:北京
- C#回调函数求解
- 我的c#生成的exe文件在其他机器上怎么不能执行???
- 请问用c#开发手机等移动设备应用程序需要哪些东西?
- VS2015 C# Directory操作文件夹的个别问题!
- listbox用dataset绑定数据后,如何访问listbox中的数据
- 我把ChinaMVP论坛 v1.3的界面先调整了一下,下一步准备对功能进行修改!
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace JulBook
{
/// <summary>
/// index 的摘要说明。
/// </summary>
public class index : System.Web.UI.Page
{
protected System.Data.OleDb.OleDbDataAdapter da;
protected System.Data.DataSet ds;
protected System.Web.UI.WebControls.Label info;
private int pageSize=3;
public static int fv;
protected System.Web.UI.WebControls.Button pre;
protected System.Web.UI.WebControls.Button nex;
public static int lv;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
string sql="select top "+pageSize+" * from julbook order by id desc";
OpenDb(sql);
info.Text=fv.ToString()+" "+lv.ToString();
}
} private void OpenDb(string sql){
string path=Request.PhysicalPath;
path=path.Remove(path.Length-10,10);
string constr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "julbook.mdb";
OleDbConnection conn = new OleDbConnection(constr);
da = new OleDbDataAdapter(sql,conn);
ds = new DataSet();
da.Fill(ds,"msg");
fv=(int)ds.Tables["msg"].Rows[0][0];
lv=(int)ds.Tables["msg"].Rows[pageSize - 1][0];
} private void GetD(string direct){
string sql;
switch(direct){
case "nex":
sql="select top "+pageSize+" * from julbook where id < "+lv+" order by id desc";
break;
case "pre":
sql="select * from(select top "+pageSize+" * from julbook where id > "+fv+" order by id)order by id desc";
break;
default:
sql="select top "+pageSize+" * from julbook order by id desc";
break;
}
OpenDb(sql);
info.Text=fv.ToString()+" "+lv.ToString();
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.da = new System.Data.OleDb.OleDbDataAdapter();
this.ds = new System.Data.DataSet();
((System.ComponentModel.ISupportInitialize)(this.ds)).BeginInit();
//
// ds
//
this.ds.DataSetName = "NewDataSet";
this.ds.Locale = new System.Globalization.CultureInfo("zh-CN");
this.pre.Click += new System.EventHandler(this.pre_Click);
this.nex.Click += new System.EventHandler(this.nex_Click);
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.ds)).EndInit(); }
#endregion private void pre_Click(object sender, System.EventArgs e)
{
GetD("pre");
} private void nex_Click(object sender, System.EventArgs e)
{
GetD("nex");
}