Adds

Thursday, 13 June 2013

C# Custom GridView PageIndex / Pagination

Function for page index change (in aspx.cs page)

protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grdvAttendance.DataSource = a.GetAllByDate(Convert.ToDateTime(DateTime.Now.ToString("MMM-d, yyyy")));
            grdvAttendance.PageIndex = e.NewPageIndex;
            grdvAttendance.DataBind();
        }
 Call The Function in Gridview Control (in aspx page)


<asp:GridView ID="grdvAttendance" runat="server" AutoGenerateColumns="False"
        AllowPaging="true" PageSize="5" OnPageIndexChanging="gridView_PageIndexChanging">
</asp:GridView>