这是我的 repeater 分页的代码,但是运行起来总是报错.请高手帮忙解决

reyeryeryetteyt 2004-10-26 01:24:37
System.Data.SqlClient.SqlConnection connect =new System.Data.SqlClient.SqlConnection();
string con = System.Configuration.ConfigurationSettings.AppSettings.Get(0);

private void Page_Load(object sender, System.EventArgs e)
{
string com ="Select * From list Order By [time] DESC";
this.connect.ConnectionString=this.con;
this.connect.Open();
this.sa=new System.Data.SqlClient.SqlDataAdapter(com,this.connect);
this.ds.Clear();
this.sa.Fill(ds,"table");
this.Repeater1.DataSource=this.ds.Tables["table"];
this.Repeater1.DataBind();
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 5;
int CurPage;
if (Request.QueryString["Page"] != null)
CurPage=Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage=1;
objPds.CurrentPageIndex = CurPage-1;
lblCurrentPage.Text = "当前页:" + CurPage.ToString();

if (!objPds.IsFirstPage)
lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage-1);

if (!objPds.IsLastPage)
lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+ "?Page=" + Convert.ToString(CurPage+1);

Repeater1.DataSource=objPds;
Repeater1.DataBind();

this.connect.Close();


}
...全文
37 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
lingwu05 2004-10-26
用viewState吧。
回复
相关推荐
发帖
.NET技术社区
创建于2007-09-28

5.8w+

社区成员

.NET技术交流专区
申请成为版主
帖子事件
创建了帖子
2004-10-26 01:24
社区公告
暂无公告