Search code examples
c#asp.netpage-index-changed

Pageindex is not work properly


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.


Solution

  • Change the PageIndex before you DataBind the GridView.