高手帮我看看代码,刷新过多就出错
高手帮我看看代码,本人第一次写代码可能好多地方不规范,刷新过多就出现未指定的错误,CS代码如下:
private void dataBindToDatalist()
{
int curPage = Convert.ToInt32(this.Label2.Text);
OleDbConnection con = db.creater();
OleDbDataAdapter oda = new OleDbDataAdapter();
oda.SelectCommand = new OleDbCommand( "select * from guestbook where allow=true order by id desc ", con);
DataSet ds = new DataSet();
oda.Fill(ds, "book ");
this.DataList1.DataKeyField = "id ";
System.Web.UI.WebControls.PagedDataSource ps = new PagedDataSource();
ps.DataSource = ds.Tables[ "book "].DefaultView;
ps.AllowPaging = true;
ps.PageSize = 4;
ps.CurrentPageIndex = curPage - 1;
this.LinkButton1.Enabled = true;
this.LinkButton2.Enabled = true;
if (curPage == 1)
{
this.LinkButton1.Enabled = false;
}
if (curPage == ps.PageCount)
{
this.LinkButton2.Enabled = false;
}
this.DataList1.DataSource = ps;
this.DataList1.DataBind();
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (Request.Cookies[ "user "] == null)
{
Response.Write( " <script> alert( '您还没有登录,请先登录! ') </script> ");
}
else
{
if (String.Compare(Session[ "CheckCode "].ToString(), this.TextBox6.Text, true) != 0)