日期:2014-05-17 浏览次数:20510 次
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bind();
}
}
void bind()
{
int curpage = Convert.ToInt32(this.Label1.Text);
PagedDataSource ps = new PagedDataSource();
pagebind(ps);
ps.AllowPaging = true;
ps.PageSize = 5;
ps.CurrentPageIndex = curpage -1;
this.LinkButton1.Enabled = true;
this.LinkButton2.Enabled = true;
this.LinkButton3.Enabled = true;
this.LinkButton4.Enabled = true;
if (curpage == 1)
{
this.LinkButton1.Enabled = false;
this.LinkButton2.Enabled = false;
}
if (curpage == ps.PageCount)
{
this.LinkButton3.Enabled = false;
this.LinkButton4.Enabled = false;
}
this.Label2.Text = ps.PageCount.ToString();
this.DataList1.DataSource = ps;
this.DataList1.DataBind();
}
void pagebind(PagedDataSource pd)
{
string strcon="server=.;database=pubs;uid=sa;pwd=sa";
SqlConnection cn = new SqlConnection(strcon);
SqlDataAdapter da = new SqlDataAdapter("select title_id,title,price from titles