GridView改变显示条件后如何重新绑定分页函数
上面3个图是我要解释的,我刚学net很多东西搞不清楚,请大家帮一下
默认打开这个页面时,显示的是第一个图,绑定分页,
然后通过dropdownlist改变这个页面显示的内容,然后再绑定分页就迷糊了,出现了第三种情况
就是点击分页后,绑定了默认的情况而不是我选择的条件,代码如下:
public partial class _Admin_Order_Form_List : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
bandpage();
}
}
private void bandpage()
{
SqlConnection con = Dataconn.createconn();
con.Open();
SqlDataAdapter sda = new SqlDataAdapter("select * from Order_Form", con);
DataSet ds = new DataSet();
//将数据填充到Dataset数据集中
sda.Fill(ds);
this.OrderList.DataSource = ds;
this.OrderList.DataBind();
con.Close();
}
protected void OrderList_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.OrderList.PageIndex = e.NewPageIndex;
bandpage();
}
protected void Ddl_SelectedIndexChanged(object sender, EventArgs e)
{
int sid = int.Parse(this.Ddl.SelectedValue.ToString());
SqlConnection con = Dataconn.createconn();
con.Open();
if (sid == 0)
{
SqlDataAdapter sda = new SqlDataAdapter("select * from Order_Form", con);
DataSet ds = new DataSet();
//将数据填充到Dataset数据集中
sda.Fill(ds);
this.OrderList.DataSource = ds;
this.OrderList.DataBind();
con.Close();
}
else
{
SqlDataAdapter sda = new SqlDataAdapter("select * from Order_Form where Order_Lc=" + sid, con);
DataSet ds = new DataSet();
//将数据填充到Dataset数据集中
sda.Fill(ds);
this.OrderList.DataSource = ds;
this.OrderList.DataBind();
con.Close();
}
}
}
主要还是不知道换了条件后该如何再次使用OrderList_PageIndexChanging