Gridview自帶分頁問題,謝謝
有兩頁面A,B,
A向B頁面傳一參數flag,
B頁面判斷flag為1時bind1(),為2時bind2(),頁面高了 AllowPaging= "True " OnPageIndexChanging= "GridView1_PageIndexChanging " PageSize= "15 "
PageIndexChanging事件我這樣寫,好像不對
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
if (flag == "1 ")
{
bind();
}
if (flag == "2 ")
{
bind1();
}
}
------解决方案--------------------可能發生碰撞
------解决方案--------------------if (!IsPostBack)
{
ViewState[flag2] = Request.QueryString[ "flag2 "];
if(ViewState[flag2].Tostring()== "1 ")
{
bind();
}
if(ViewState[flag2].Tostring()== "2 ")
{
bind1();
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
if (ViewState[flag2].Tostring() == "1 ")
{
bind();
}
if (ViewState[flag2].Tostring()== "2 ")
{
bind1();
}
}