Monday, 25 June 2012

HOW TO DISPLAY LAST PAGE OF GRID VIEW ON PAGE LOADING

 ASPX :

 <asp:gridview id="Gridview1" runat="server" allowpaging="true" onpageindexchanging="GridView1_PageIndexChanging">
 </asp:gridview>


C# :

protected void Page_Load(object sender, EventArgs e)
  {

            if (!IsPostBack)
            {             
                Gridview1.PageIndex = Int32.MaxValue;
                bindGridData();              
            }

   }

protected void gvJobCard_RowDataBound(object sender, GridViewRowEventArgs e)
{           
           Gridview1.PageIndex = gvJobCard.PageCount - 1;           
}

protected void gvJobCard_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
            gvJobCard.PageIndex = e.NewPageIndex;
            this.bindGridData();
 }


Reply if any query !!
Happy Coding :)

No comments:

Post a Comment