나는 목록 항목이 거의없는 DropDownList를 사용하고 있습니다. 모든 항목을 선택할 때마다 그리드 뷰를 바인딩하므로 그리드 뷰는 내 선택에 달려 있습니다. 일부 결과는 페이지 크기를 초과하므로 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 –