if (!IsPostBack)
{
ViewState["pageindex"] = "0";
BindData();
for (int i = 0; i < pg.PageCount; i++)//循环,TruPage.PageCount分页的总数
{
DropDownList3.Items.Add(new ListItem("第 " + Convert.ToInt32((i + 1)) + " 頁", (i + 1).ToString()));
}
}
private void BindData()
{
if (ViewState["pageindex"] != null)
{
DropDownList3.SelectedIndex = Convert.ToInt16(ViewState["pageindex"]);
}
else
{
DropDownList3.SelectedIndex = 0;
}
DataList1.DataSource = pg;
DataList1.DataBind();
}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
//Response.Redirect(Request.Path + "?Page=" + DropDownList3.SelectedValue.ToString());
ViewState["pageindex"] = DropDownList3.SelectedIndex;
BindData();
}