0
我有一個在頁面加載時綁定的gridview,並且我已經使用頁腳行技術實現了插入。在ASP.Net Gridview控件中實現分頁
現在我嘗試了在同一個gridview中的分頁。
我沒有錯誤,但當在頁腳行的DDL中更改頁面時,我發現所有值都重複。
在第一頁DDL輸出爲:
MSG
PAY
BUY
LIS
如果改變了頁面的頁號兩個第二輸出是:
MSG
PAY
BUY
LIS
MSG
PAY
BUY
LIS
我會非常感激的任何建議。
謝謝!
我用這行的RowDataBound:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow && GridView1.EditIndex == e.Row.RowIndex)
{
DropDownList Area_DDL = (DropDownList)e.Row.FindControl("Area_DDL");
Area_DDL.DataTextField = "area_name";
Area_DDL.DataValueField = "area";
Area_DDL.DataSource = Area();
Area_DDL.DataBind();
Area_DDL.Items.FindByValue((e.Row.FindControl("Area") as Label).Text).Selected = true;
}
if (e.Row.RowType == DataControlRowType.Footer)
{
DropDownList Area_DDL = (DropDownList)e.Row.FindControl("Area_DDL");
Area_DDL.DataTextField = "area_name";
Area_DDL.DataValueField = "area";
Area_DDL.DataSource = Area();
Area_DDL.DataBind();
}
if (e.Row.RowType == DataControlRowType.Pager)
{
DropDownList ddl = (DropDownList)(e.Row.FindControl("ddlpages"));
Label lblPageCount = (Label)e.Row.FindControl("lblPageCount");
if (lblPageCount != null)
lblPageCount.Text = GridView1.PageCount.ToString();
for (int i = 1; i <= GridView1.PageCount; i++)
{
ddl.Items.Add(i.ToString());
}
ddl.SelectedIndex = GridView1.PageIndex;
if (GridView1.PageIndex == 0)
{
((ImageButton)e.Row.FindControl("ImageButton1")).Visible = false;
((ImageButton)e.Row.FindControl("ImageButton2")).Visible = false;
}
if (GridView1.PageIndex + 1 == GridView1.PageCount)
{
((ImageButton)e.Row.FindControl("ImageButton3")).Visible = false;
((ImageButton)e.Row.FindControl("ImageButton4")).Visible = false;
}
}
}
大,非常感謝你! – 2014-09-05 15:07:46