Click here to Skip to main content
15,896,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my application i have to find the last page in gridview paging when user clicks on the paging in gridview how can i do this in pageindexchanging of gridview


What I have tried:

i could not find source for doing this
Posted
Updated 12-Jan-18 2:19am
Comments
kav@94 12-Jan-18 8:28am    
below is my pageindexchanging method the total which i am getting in ViewState["Result1".tostring() should be binded to last page of my gridview how can i do this can anyone help me out
protected void grd_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
DataTable dt = (DataTable)ViewState["grd"];
if (dt.Rows.Count > 0)
{
grd.PageIndex = e.NewPageIndex;
grd.DataSource = dt;
grd.DataBind();

grd.FooterRow.Cells[6].Text = "Total:";
grd.FooterRow.Cells[6].HorizontalAlign = HorizontalAlign.Left;
grd.FooterRow.Cells[7].Text = ViewState["Result1"].ToString();
grd.FooterRow.Cells[6].Font.Size = 15;
grd.FooterRow.Cells[7].Font.Size = 15;
}
else
{
grdUser.DataSource = null;
grdUser.DataBind();
}
}

1 solution

Quote:
How to get which page is clicked by the user in gridview paging
C#
int newPage = e.NewPageIndex;

Quote:
i have to find the last page in gridview paging
C#
int lastPage = gridView.PageCount -1;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900