欢迎来到天天文库
浏览记录
ID:9281814
大小:39.50 KB
页数:4页
时间:2018-04-26
《repeater分页实例》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、repeater分页实例usingSystem;usingSystem.Data;usingSystem.Data.SqlClient;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSy
2、stem.Web.UI.HtmlControls;publicpartialclassrepeate:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){Repeater1.DataSource=pds();Repeater1.DataBind();}}privatePagedDataSourcepds(){stringconnstring=ConfigurationManager.Connec
3、tionStrings["pconn"].ConnectionString;SqlConnectioncon=newSqlConnection(connstring);DataSetds=newDataSet();SqlDataAdaptersda=newSqlDataAdapter("select*fromauthors",con);sda.Fill(ds,"name");SqlDataAdaptersda2=newSqlDataAdapter("select*fromtitleauthor",con);
4、sda2.Fill(ds,"title");ds.Relations.Add("myrela",ds.Tables["name"].Columns["au_id"],ds.Tables["title"].Columns["au_id"]);PagedDataSourcepds=newPagedDataSource();pds.DataSource=ds.Tables["name"].DefaultView;pds.AllowPaging=true;//允许分页pds.PageSize=5;//单页显示项数p
5、ds.CurrentPageIndex=Convert.ToInt32(Request.QueryString["page"]);returnpds;}protectedvoidRepeater1_ItemDataBound(objectsender,RepeaterItemEventArgse){if(e.Item.ItemType==女包、名牌包、背包:www.naitiao.com
6、冬装新款、流行冬装、今年流行秋冬装:dongzhuang.qqxk.netListItemType.Footer){Dr
7、opDownListddlp=(DropDownList)e.Item.FindControl("ddlp");HyperLinklpfirst=(HyperLink)e.Item.FindControl("hlfir");HyperLinklpprev=(HyperLink)e.Item.FindControl("hlp");HyperLinklpnext=(HyperLink)e.Item.FindControl("hln");HyperLinklplast=(HyperLink)e.Item.Find
8、Control("hlla");pds().CurrentPageIndex=ddlp.SelectedIndex;intn=Convert.ToInt32(pds().PageCount);//n为分页数inti=Convert.ToInt32(pds().CurrentPageIndex);//i为当前页Labellblpc=(Label)e.Item.FindControl("lblpc");lblpc.Text=n.ToString();Labellblp=(Label)e.Item.FindCon
9、trol("lblp");lblp.Text=Convert.ToString(pds().CurrentPageIndex+1);if(!IsPostBack){for(intj=0;j
此文档下载收益归作者所有