Question

i try in button control:

protected void btnImgBack_Click(object sender,EventArgs e)
 {
   try
   {
     gdvFile.DataSource = GetFiles();
     gdvFile.DataBind();
     gdvFile.PageIndex=1;
   }
   catch(Exception ex)
   {
     throw ex;
   }
 }

If btnImgBack is click i want to go back in page 1 of grid .But instead of going page 1 i am in same page.PageIndex is not work for this or i mistake some thing else?Thanks.

Was it helpful?

Solution

Change the PageIndex before you DataBind the GridView.

OTHER TIPS

Difficult to say with so little information, but things to remember:

  1. PageIndex is a zero based index therefore PageIndex=1 will set the current page to the SECOND page.
  2. AllowPaging must be true for PageIndex to work.
 protected void btnImgBack_Click(object sender,EventArgs e)
 {
   try
   {
     gdvFile.DataSource = GetFiles();
     gdvFile.PageIndex=1;
     gdvFile.DataBind();
   }
   catch(Exception ex)
   {
     throw ex.Message;
   }
 }

this is also assuming that the GetFile() method returns without any errors as well

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top