久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

Repeater讀取數(shù)據(jù)并分頁

 悟靜 2012-01-30

據(jù)說這個(gè)沒有什么用,,但是把這個(gè)搞懂了對(duì)datagri和datalist和有幫助,事業(yè)就筆記一下了,。
----------控件清單---------
Panel Panel1;
Button Button1;
Button Button2;
Label Label1;
Label Label2;
Label Label3;
Label Label4;
Label Label5;
Repeater Repeater1;

--------------------------.cs頁-----------------------------------
private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
this.Label1.Text="1";
this.fill();
}
}
private void fill()
{
int pag=Convert.ToInt32(this.Label1.Text);//設(shè)置當(dāng)前頁
SqlConnection con=new SqlConnection("server=.;database=Northwind;uid=sa;pwd=980123;");//實(shí)例化連接
SqlDataAdapter sda=new SqlDataAdapter();//建立一個(gè)數(shù)據(jù)適配器對(duì)象
sda.SelectCommand=new SqlCommand("select * from Employees",con);//實(shí)例化SelectCommand,,并用他從數(shù)據(jù)庫讀出全部數(shù)據(jù)
DataSet ds=new DataSet();//定義一個(gè)數(shù)據(jù)集填充
sda.Fill(ds,"name");//使用適配器填充數(shù)據(jù)集到本地表“name”
PagedDataSource ps=new PagedDataSource();//實(shí)例化一個(gè)PagedDataSource,這個(gè)本來是封裝是DATAGRID里面的
ps.DataSource=ds.Tables["name"].DefaultView;//設(shè)置他的數(shù)據(jù)源為ds.Tables["name"].DefaultView數(shù)據(jù)視圖
ps.AllowPaging=true;//允許分頁
ps.PageSize=3;//每頁顯示數(shù)量
ps.CurrentPageIndex=pag-1;//當(dāng)前頁碼,,因?yàn)轫撌菑?開始的,,所以要減1
this.Button1.Enabled=true;//按鈕當(dāng)前狀態(tài)
this.Button2.Enabled=true;
this.Label5.Text=ps.PageCount.ToString();
if(pag==1)
{
this.Button1.Enabled=false;//如果當(dāng)前頁是 1 ,上一頁按鈕不可用
}
if(pag==ps.PageCount)
{
this.Button2.Enabled=false;//如果當(dāng)前頁是最后一頁 ,,下一頁按鈕不可用
}
this.Repeater1.DataSource=ps;
this.Repeater1.DataBind();
}
窗體代碼
private void Button2_Click(object sender, System.EventArgs e)
{
this.Label1.Text=((Convert.ToInt32(this.Label1.Text))+1).ToString();
this.fill();
}

private void Button1_Click(object sender, System.EventArgs e)
{
this.Label1.Text=((Convert.ToInt32(this.Label1.Text))-1).ToString();
this.fill();
}

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn),。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請遵守用戶 評(píng)論公約

    類似文章 更多