I have a web app where everytime I upload an Excel file, its contents appears in Gridview, which is binded with a DataTable. Using the properties, I have set paging and sorting to true.
When I input a file using fileupload and a submit button, the web app has page numbers at the bottom appear. It also correctly sorts it, (my page size is set to 10), however, when i click on the next page (pg 2, for instance), nothing shows up until i upload the another file and hit submit again.
This is the code in which I build the table:
protected void AddResultToGrid(String url, String result)
{
data = (DataTable)Session["URLSessionData"];
DataRow dr = data.NewRow();
dr[0] = url;
dr[1] = result;
data.Rows.Add(dr);
gdvResults.DataSource = data;
gdvResults.DataBind();
Session["URLSessionData"] = data;
}
This is the page load:
protected void Page_Load(object sender, EventArgs e)
{
lblFiup.Text = "";
data.Columns.Add("URL", typeof(String));
data.Columns.Add("Status", typeof(String));
gdvResults.DataSource = data;
gdvResults.DataBind();
gdvResults.AllowPaging = true;
gdvResults.AllowSorting = true;
if (!Page.IsPostBack)
{
Session["URLSessionData"] = data;
}
}
I think it may have something to do with the page index... but i'm not sure. Here's my page index change method:
protected void gdvResults_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
e.NewPageIndex = e.NewPageIndex + 1;
DataBind();
}
Thanks in advance for your help (: