我在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();
}
答案 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
}