public void sel_callname()
{
PagedDataSource ps = new PagedDataSource();//用來給數據控件顯示分頁的類不能繼承
int curpage = Convert.ToInt32(this.lblCurrentIndex.Text.Trim());
//獲取數據源
string sqlstr = "select articleid,title,classname,username,dateandtime From db_article";
com = new SqlCommand(sqlstr, con);
com.CommandType = CommandType.Text;
da = new SqlDataAdapter();
da.SelectCommand = com;
ds = new DataSet();
da.Fill(ds);
ps.DataSource = ds.Tables[0].DefaultVIEw;
ps.AllowPaging = true;//是否可以分業
ps.PageSize = 3;//每頁顯示數據的數量
ps.CurrentPageIndex = curpage - 1;//取得當前的頁碼
this.LinkButton2.Enabled = true;
this.Linkbutton3.Enabled = true;
this.Linkbutton4.Enabled = true;
this.lblCurrentIndex.Enabled = true;
//如果是當前第一頁
if (curpage == 1)
{
this.btnFirst.Enabled = false;//不顯示第一頁按鈕
this.LinkButton2.Enabled = false;//不顯示上一頁按鈕
}
//如果是最後一頁
if (curpage == ps.PageCount)
{
&nb
sp; this.Linkbutton3.Enabled = false;//不顯示下一頁按鈕
this.Linkbutton4.Enabled = false;//不顯示最後一頁按鈕
}
this.lblPageCount.Text = Convert.ToString(ps.PageCount);//得到最後一頁
for (int i = 1; i <= ps.PageCount; i++)//填充下拉列表值
{
DropDownList2.Items.Add("" + i);
}
try
{
GridVIEw1.DataSource = ps;
GridVIEw1.DataBind();
}
catch (SqlException ex)
{
myLabel.Text = "數據庫錯誤!" + ex.Message;
}
finally
{
ds.Clone();
com.Clone();
con.Close();
}
}
//怎樣獲得給DataList中添加一個Bootn按鈕進行刪除的功能
//首先綁定datalist,str是傳進來的任何有效的sql查詢語句
protected void Data_x(string str)
{
con = new SqlConnection(ConfigurationSettings.APPSettings["dsn"]);
da = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
try
{
&nbs
xtext from bbs_xinxi where xjname=''" + u_name +