更新面板中的gridview pageindex

时间:2013-04-10 07:00:34

标签: asp.net gridview indexing updatepanel page-index-changed

我在updatepanel里面有一个gridview,在第一次点击页面索引正在改变但后来点击页面索引没有改变。但点击时会触发事件。 这就是我绑定数据的方式。

protected void gvPurchaseDetails_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    gvPurchaseDetails.PageIndex = e.NewPageIndex;
    DetailsGridBind();
}

public void DetailsGridBind()
{

    DataSet dsInvoice = ObjDetail.GetPurchaseDetails();
    DataTable dtInvoice = dsInvoice.Tables[0];
    gvPurchaseDetails.DataSource = dtInvoice;
    gvPurchaseDetails.DataBind();     
}

1 个答案:

答案 0 :(得分:1)

EnableSortingAndPagingCallbacks="true"

设置GridView

默认设置为false

此外,在更新您的UpdatePanel

后面的代码中
protected void gvPurchaseDetails_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    gvPurchaseDetails.PageIndex = e.NewPageIndex;
    DetailsGridBind();

    yourUpdatePanelId.Update();   // add this line of code was well
}