Rinshad Hameed
Rinshad Hameed

Reputation: 117

gridview pageindex in update panel

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();     
}

Upvotes: 1

Views: 3026

Answers (1)

Praveen Nambiar
Praveen Nambiar

Reputation: 4892

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
}

Upvotes: 1

Related Questions