DataTable dt = dbObject.BothEnExamCenter.FromSql(sql.ToString()).ToTable();
int cup = this.drpCurrentPageIndex.SelectedValue == "" ? 1 : Convert.ToInt32(this.drpCurrentPageIndex.SelectedValue);
PagedDataSource objPage = new PagedDataSource();
objPage.DataSource = dt.DefaultView;
objPage.AllowPaging = true;
objPage.PageSize = Convert.ToInt32(drpCount.SelectedValue);
objPage.CurrentPageIndex = cup - 1;
ViewState["PageCount"] = objPage.PageCount;
lbPageCount.Text = "一共" + ViewState["PageCount"] + "页";
//绑定当前页
if (!IsPostBack)
{ //drpCurrentPageIndex.Items.Clear();
for (int i = 1; i < Convert.ToInt32(ViewState["PageCount"]) + 1; i++)
{ this.drpCurrentPageIndex.Items.Add(i.ToString());
}
}
else {
//drpCurrentPageIndex.SelectedIndex = -1;
drpCurrentPageIndex.Items.Clear();
for (int i = 1; i < Convert.ToInt32(ViewState["PageCount"]) + 1; i++) {
this.drpCurrentPageIndex.Items.Add(i.ToString());
}
}
drpCurrentPageIndex.SelectedValue = cup.ToString();
rpQuestionLine.DataSource = objPage;
rpQuestionLine.DataBind();
protected void LinkUp_Click(object sender, EventArgs e)
{ if (Convert.ToInt32(drpCurrentPageIndex.SelectedValue) > 1) {
drpCurrentPageIndex.SelectedValue = (Convert.ToInt32(drpCurrentPageIndex.SelectedValue) - 1).ToString(); BindrpQuestionLine(); } else { PublicObject.PageHelper.Alert(this, "已经第一页");
} }
protected void LinkDown_Click(object sender, EventArgs e) { if (Convert.ToInt32(drpCurrentPageIndex.SelectedValue) < Convert.ToInt32(ViewState["PageCount"])) { drpCurrentPageIndex.SelectedValue = (Convert.ToInt32(drpCurrentPageIndex.SelectedValue) + 1).ToString(); BindrpQuestionLine(); } else { PublicObject.PageHelper.Alert(this, "已经到了最后一页"); } }
protected void drpCurrentPageIndex_SelectedIndexChanged(object sender, EventArgs e) { int page = Convert.ToInt32((drpCurrentPageIndex.SelectedItem.Value)); BindrpQuestionLine(); }
protected void LinkFirst_Click(object sender, EventArgs e) { this.drpCurrentPageIndex.SelectedValue = "1"; BindrpQuestionLine(); }
protected void LinkLast_Click(object sender, EventArgs e) { this.drpCurrentPageIndex.SelectedValue = ViewState["PageCount"].ToString(); BindrpQuestionLine(); }
protected void drpCount_SelectedIndexChanged(object sender, EventArgs e) { this.drpCurrentPageIndex.SelectedValue = "1"; BindrpQuestionLine(); }