hi,
here an example i use "ProductInfo" class for GridView DataSource, "dtgView" my GridView and "lblPageInfo Label for display page information. You need to GridView AllowPaging="True" and generate OnPageIndexChanging="dtgView_PageIndexChanging" Event for paging your GridView.
then need to Bind GridView on page load code below:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<productinfo> list = new ProductInfo().SelectAll4Grid();
dtgView.DataSource = list;
dtgView.DataBind();
lblPageInfo.Text = "you are viewing page 1 of " + dtgView.PageCount.ToString();
}
}
</productinfo>
then you need to Bind GridView on page index changing event and collect your page information code below:
protected void dtgView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
List<productinfo> list = new ProductInfo().SelectAll4Grid();
dtgView.PageIndex = e.NewPageIndex;
lblPageInfo.Text = "you are viewing page " + (e.NewPageIndex + 1).ToString() + " of " + dtgView.PageCount.ToString();
dtgView.DataSource = list;
dtgView.DataBind();
}
</productinfo>
it's working on my project. try use it.