Question

I have a gridview inside an updatepanel ,on first click the page index is changing but later clicks the page indexes are not changing. but the events are triggering when click. this is how i bind data.

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();     
}
Était-ce utile?

La solution

Set EnableSortingAndPagingCallbacks="true" for your GridView

By default its set to false

Also in the code behind update your UpdatePanel

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

    yourUpdatePanelId.Update();   // add this line of code was well
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top