using System;
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.SqlClient;
using System.Configuration;
namespace baogelyb
{
/// <summary>
/// showguestbook 的摘要说明。
/// </summary>
public class showguestbook : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataList DataList1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Button Button4;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button5;
protected System.Web.UI.HtmlControls.HtmlForm Form1;

private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
this.Label2.Text="1";
this.databind();
this.TextBox1.Text="1";
}
}// public string ShowReply(bool IsReplyed, string replytime, string replycontent)
// {
// if (!IsReplyed)
// {
// return "";
// }
// else
// {
// return "<br><hr size=1 width=100% align=center><font color=#009966>管理员于 '"+replytime+"' 回复</font><br><font color=#666666>'"+replycontent.Replace("\r\n","<br>")+"</font>";
// }
// }
private void databind()
{
// int CID=Convert.ToInt32(Request.QueryString["id"]);
int curPage=Convert.ToInt32(this.Label2.Text);
// string dbPath=System.Configuration.ConfigurationSettings.AppSettings["bjdzqclyb"];
// //定义连接字符串
// string ConnStr="Provider=Microsoft.Jet.Sql.4.0;Data Source="+Server.MapPath(dbPath);
//创建数据库对像
// SqlConnection connection=new SqlConnection(ConnStr);
SqlConnection connection=db.createconnection();// String mysql="SELECT * FROM bjdzqclyb order by id desc";
// String mysql="SELECT * FROM Article where ispic=true order by ArticleID desc";
SqlDataAdapter sda=new SqlDataAdapter();

            sda.SelectCommand=new SqlCommand("select * from bjdzqclyb order by id desc",connection);
DataSet ds=new DataSet();
sda.Fill(ds,"bjdzqclyb");
System.Web.UI.WebControls.PagedDataSource ps=new PagedDataSource();
ps.DataSource=ds.Tables["bjdzqclyb"].DefaultView;
ps.AllowPaging=true;
ps.PageSize=5;
ps.CurrentPageIndex=curPage-1;
this.Button1.Enabled=true;
this.Button2.Enabled=true;

if(curPage==1)
{
this.Button1.Enabled=false;
}
if(curPage==ps.PageCount)
{
this.Button2.Enabled=false;
}


this.DataList1.DataSource=ps;
this.DataList1.DataBind();
this.Label3.Text=Convert.ToString(ps.PageCount);
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{    
this.DataList1.SelectedIndexChanged += new System.EventHandler(this.DataList1_SelectedIndexChanged);
this.Button3.Click += new System.EventHandler(this.Button3_Click);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Button4.Click += new System.EventHandler(this.Button4_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
this.Label2.Text=Convert.ToString(Convert.ToInt32(this.Label2.Text)-1);
this.databind();
} private void Button2_Click(object sender, System.EventArgs e)
{
this.Label2.Text=Convert.ToString(Convert.ToInt32(this.Label2.Text)+1);
this.databind();
} private void Button3_Click(object sender, System.EventArgs e)
{
this.Label2.Text="1";
this.databind();
} private void Button4_Click(object sender, System.EventArgs e)
{
this.Label2.Text=Convert.ToString(Convert.ToInt32(this.Label3.Text));
this.databind();
} private void Button5_Click(object sender, System.EventArgs e)
{
if(this.TextBox1.Text.ToString()=="0")
{
this.Label2.Text="1";
this.databind();
}
else if(this.TextBox1.Text.ToString()=="")
{
this.Label2.Text="1";
this.databind();
}
  
else
{
this.Label2.Text=Convert.ToString(this.TextBox1.Text);
this.databind();
}
} private void DataList1_SelectedIndexChanged(object sender, System.EventArgs e)
{

}
}
}
这个是小弟回复区域的代码!请各位帮小弟改改..没有回复不显示..只有回复了才显示出来