repeater分頁 內(nèi)容顯示
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
namespace note
{
/// <summary>
/// _default 的摘要說明。
/// </summary>
public class _default : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Repeater rpt_sword_list;
protected System.Web.UI.WebControls.Label lbl_count;
protected System.Web.UI.WebControls.Label lbl_current_page;
protected System.Web.UI.WebControls.Label lbl_total_page;
protected System.Web.UI.WebControls.LinkButton lb_frist;
protected System.Web.UI.WebControls.LinkButton lb_p;
protected System.Web.UI.WebControls.LinkButton lb_n;
protected System.Web.UI.WebControls.LinkButton lb_last;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁面
if(!this.IsPostBack)
{
this.DB_Bind();
}
}
private void DB_Bind()
{
int ipageindex = Convert.ToInt32(this.lbl_current_page.Text);
OleDbConnection conn = dbconn.CreateConn();
OleDbCommand cmd = new OleDbCommand("select * from a where flag=true order by cdate desc",conn);
OleDbDataAdapter oda = new OleDbDataAdapter();
oda.SelectCommand = cmd;
DataSet ds = new DataSet();
oda.Fill(ds,"sword_list");
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables["sword_list"].DefaultView;
pds.AllowPaging = true;
pds.PageSize = 5;
pds.CurrentPageIndex = ipageindex - 1;
this.lbl_total_page.Text = pds.PageCount.ToString();
this.lbl_count.Text = pds.Count.ToString();
this.lb_frist.Enabled = true;
this.lb_p.Enabled = true;
this.lb_n.Enabled = true;
this.lb_last.Enabled = true;
if(this.lbl_current_page.Text=="1")
{
this.lb_frist.Enabled = false;
this.lb_p.Enabled = false;
}
if(this.lbl_current_page.Text==pds.PageCount.ToString())
{
this.lb_n.Enabled = false;
this.lb_last.Enabled = false;
}
this.rpt_sword_list.DataSource = pds;
this.rpt_sword_list.DataBind();
conn.Close();
}
#region Web 窗體設(shè)計器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調(diào)用是 ASP.NET Web 窗體設(shè)計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.lb_frist.Click += new System.EventHandler(this.lb_frist_Click);
this.lb_p.Click += new System.EventHandler(this.lb_p_Click);
this.lb_n.Click += new System.EventHandler(this.lb_n_Click);
this.lb_last.Click += new System.EventHandler(this.lb_last_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void lb_frist_Click(object sender, System.EventArgs e)
{
this.lbl_current_page.Text = "1";
this.DB_Bind();
}
private void lb_p_Click(object sender, System.EventArgs e)
{
this.lbl_current_page.Text = Convert.ToString(Convert.ToInt32(this.lbl_current_page.Text)-1);
this.DB_Bind();
}
private void lb_n_Click(object sender, System.EventArgs e)
{
this.lbl_current_page.Text = Convert.ToString(Convert.ToInt32(this.lbl_current_page.Text)+1);
this.DB_Bind();
}
private void lb_last_Click(object sender, System.EventArgs e)
{
this.lbl_current_page.Text = this.lbl_total_page.Text;
this.DB_Bind();
}
}
}
- asp.net repeater手寫分頁實(shí)例代碼
- asp.net Repeater之非常好的數(shù)據(jù)分頁
- asp.net下Repeater使用 AspNetPager分頁控件
- asp.net中讓Repeater和GridView支持DataPager分頁
- asp.net Repeater分頁實(shí)例(PageDataSource的使用)
- Repeater控件與PagedDataSource結(jié)合實(shí)現(xiàn)分頁功能
- asp.net中使用 Repeater控件拖拽實(shí)現(xiàn)排序并同步數(shù)據(jù)庫字段排序
- 在ASP.NET 2.0中操作數(shù)據(jù)之四十二:DataList和Repeater數(shù)據(jù)排序(一)
- 在ASP.NET 2.0中操作數(shù)據(jù)之四十三:DataList和Repeater數(shù)據(jù)排序(二)
- 在ASP.NET 2.0中操作數(shù)據(jù)之四十四:DataList和Repeater數(shù)據(jù)排序(三)
相關(guān)文章
在ASP.NET 2.0中操作數(shù)據(jù)之三十:格式化DataList和Repeater的數(shù)據(jù)
本文主要介紹ASP.NET 2.0使用DataList和Repeater如何呈現(xiàn)數(shù)據(jù),一種是在控件的ItemDataBound事件中處理,一種則是在綁定數(shù)據(jù)時調(diào)用后臺定義的方法來實(shí)現(xiàn)。2016-05-05在ASP.NET 2.0中操作數(shù)據(jù)之六十八:為DataTable添加額外的列
本文介紹并使用TableAdapter向DataTable添加新的一列的方法和步驟,任何時候只要重新運(yùn)行TableAdapter設(shè)置向?qū)?,用戶所做的所有定制都要被覆蓋,為避免出現(xiàn)這種情況,我們建議直接修改存儲過程。2016-05-05在ASP.NET 2.0中操作數(shù)據(jù)之四十六:使用SqlDataSource控件檢索數(shù)據(jù)
在前面的教程里,我們用ObjectDataSource控件充分的將表現(xiàn)層和數(shù)據(jù)訪問層(DAL)分開來。在這篇教程里我們看看怎樣在一個表現(xiàn)層和數(shù)據(jù)訪問層區(qū)分的不是很嚴(yán)格的簡單程序中使用SqlDataSource控件。2016-05-05Microsoft .Net Remoting系列教程之二:Marshal、Disconnect與生命周期以及跟蹤服務(wù)
本文主要講解.Net Remoting中Marshal、Disconnect與生命周期以及跟蹤服務(wù),需要的朋友可以參考下。2016-05-05在ASP.NET 2.0中操作數(shù)據(jù)之一:創(chuàng)建一個數(shù)據(jù)訪問層
本文主要介紹創(chuàng)建數(shù)據(jù)訪問層的具體步驟,從配置數(shù)據(jù)庫連接到插入,更新和刪除數(shù)據(jù)的具體實(shí)現(xiàn)方法,希望對大家有所幫助。2016-04-04在ASP.NET 2.0中操作數(shù)據(jù)之六:編程設(shè)置ObjectDataSource的參數(shù)值
本文主要介紹在ObjectDataSource控件的Selecting事件中,設(shè)置InputParameters參數(shù),配合業(yè)務(wù)層的查詢方法,以達(dá)到查詢不同數(shù)據(jù)的目的。2016-04-04MongoDB數(shù)據(jù)庫介紹并用.NET?Core對其進(jìn)行編碼
這篇文章介紹了MongoDB數(shù)據(jù)庫并用.NET?Core對其進(jìn)行編碼,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-02-02在ASP.NET 2.0中操作數(shù)據(jù)之五十:為GridView控件添加Checkbox
本文主要介紹ASP.NET 2.0中為GridView控件添加Checkbox復(fù)選框控件的方法,并實(shí)現(xiàn)全選功能。2016-05-05ASP.NET MVC的Localization本地化多語言支持
本文主要介紹在MVC中怎么使用ASP.NET中的資源文件做本地化的支持,希望對大家有所幫助。2016-04-04Visual Studio 2017使用EF選擇MySQL數(shù)據(jù)源
這篇文章介紹了Visual Studio 2017使用EF選擇MySQL數(shù)據(jù)源,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-01-01