リスト項目がほとんどない DropDownList があります。アイテムを選択するたびに、それに基づいてグリッドビューをバインドしているため、結果のグリッドビューは選択に依存します。一部の結果がページサイズを超えているため、GridView の 2 ページ目に移動する必要がありますが、2 ページ目を選択すると 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();
}
個別のバインド機能がないため、ページング イベントでグリッドビューをバインドする方法がわかりません。