关于分页的问题
12311.zip
(2.58 KB)
我如果要实现这张图里的功能:共9条,这里需要一个统计数据,该怎么做,如果是第一页就是这样显示:第1页/共2页,如果是第二页就这样显示:第2页/共2页,点击下一页这个超链接就自动跳转到下一页,跳到的这个下拉列表框里的内容是:第一页和第二页,如果点击第一页就显示第一页的内容,如果点击第二页就显示第二页的内容。
要做到如上功能该怎么做。
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; //using System.Xml.Linq; using System.Data.OleDb; using PracticeMyBookShopBLL; using PracticeMyBookShopModels; public partial class xwdt : System.Web.UI.Page { OleDbConnection cn = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString()); int shuliang; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bb(); aa(); Label1.Text = shuliang.ToString(); ViewState["Page"] = 0; } Databind(); } public void bb() { OleDbDataAdapter da = new OleDbDataAdapter("select title,fbsj from hangye ", cn); DataSet ds = new DataSet(); da.Fill(ds); GridView1.DataSourceID = null; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } public int aa() { string str = "select count(id) as ID from hangye"; cn.Open(); OleDbCommand com = new OleDbCommand(str, cn); int set = com.ExecuteNonQuery(); cn.Close(); return set; } private void Databind() { PagedDataSource pdsList = new PagedDataSource(); pdsList.DataSource = BookManager.GetHotBooks(); pdsList.AllowPaging = true; pdsList.PageSize = 5; pdsList.CurrentPageIndex = Pager; lblCurrentPage.Text = "第 " + (pdsList.CurrentPageIndex + 1).ToString() + " 页 共 " + pdsList.PageCount.ToString() + " 页"; SetEnablE(pdsList); dlBooks.DataSource = pdsList; dlBooks.DataBind(); } private void SetEnable(PagedDataSource pds) { lnkbtnPre.Enabled = true; lnkbtnNext.Enabled = true; if (pds.IsFirstPage) { lnkbtnPre.Enabled = false; } if (pds.IsLastPage) lnkbtnNext.Enabled = false; } private int Pager { get{ return (int)ViewState["Page"]; } set { ViewState["Page"] = value; } } protected void lnkBtnPre_Click(object sender, EventArgs e) { Pager--; Databind(); } protected void lnkbtnNext_Click(object sender, EventArgs e) { Pager++; Databind(); } }这2句语句怎么会出现这个情况。,这里的Using指令集不是已经指定了吗?