我有一個DropDownList它有少數列表項。每次我選擇任何項目,基於它我綁定一個GridView,因此結果GridView取決於我的選擇。一些結果超出頁面大小,因此我需要在GridView的第二頁導航,但是當我選擇第二頁時,GridView正在消失。使用DropDown_SelectedIndexChanged綁定gridview,但分頁不起作用
protected void DDL_SelectedIndexChanged(object sender, EventArgs e)
{
string constr = ConfigurationSettings.AppSettings["ConnectionInfo"];
SqlConnection con = new SqlConnection(constr);
con.Open();
string str = string.Empty;
str = "SELECT * FROM Table1";
SqlDataAdapter adp = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
adp.Fill(ds, "myds");
BusinessKPIGrid.DataSource = ds;
BusinessKPIGrid.DataBind();
}
protected void OnGridViewPaging(object sender, GridViewPageEventArgs e)
{
//I know I need to bind the gridview here, but how ?
BusinessKPIGrid.PageIndex = e.NewPageIndex;
BusinessKPIGrid.DataBind();
}
我不知道如何在分頁事件中綁定gridview,因爲我沒有任何單獨的綁定函數。
Thnx全部。我在這裏得到了解決方案: http://forums.asp.net/t/1828875.aspx/1?Using+DropDown_SelectedIndexChanged+to+bind+gridview+but+paging+is+not+working – 2012-07-30 07:23:27