I think between both solutions it worked.
protected void LastThirtyDaysReportGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GetThirtyDay(null, null);
LastThirtyDaysGrid.PageIndex = e.NewPageIndex;
LastThirtyDaysGrid.DataBind();
}
I added the first line of code within the function. It calls the function that originally sets the GridView's data.
protected void GetThirtyDay(object sender, EventArgs e)
{
GenerateReport("LastThirtyDaysExpenses", LastThirtyDaysGrid, "Last Thirty Days' Expenses");
}
private void GenerateReport(string storedProcName, GridView reportGridview, string reportTitle)
{
ClearGridViews();
try
{
using (var conn = new SqlConnection(connectionString))
{
var command = new SqlCommand();
command.CommandText = storedProcName;
command.Connection = conn;
command.CommandType = CommandType.StoredProcedure;
var dataAdapter = new SqlDataAdapter(command);
var dataTable = new DataTable();
dataAdapter.Fill(dataTable);
reportGridview.DataSource = dataTable;
reportGridview.DataBind();
ReportHeader.Text = reportTitle;
}
}
catch (Exception exp)
{
string help = exp.ToString();
}
}