【发布时间】:2012-07-30 06:56:04
【问题描述】:
我有一个 DropDownList 列表项很少。每次我选择任何项目时,我都会基于它绑定一个网格视图,因此生成的网格视图取决于我的选择。一些结果超出了页面大小,因此我需要在 GridView 的第二页上导航,但是当我选择第二页时,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,因为我没有任何单独的绑定函数。
【问题讨论】:
标签: asp.net drop-down-menu paging selectedindexchanged