Note that there are some explanatory texts on larger screens.

plurals
  1. POPaging in Gridview, can't access another page
    primarykey
    data
    text
    <p>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.</p> <p>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.</p> <p>This is the code in which I build the table:</p> <pre><code>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; } </code></pre> <p>This is the page load:</p> <pre><code>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; } } </code></pre> <p>I think it may have something to do with the page index... but i'm not sure. Here's my page index change method:</p> <pre><code> protected void gdvResults_PageIndexChanging(object sender, GridViewPageEventArgs e) { e.NewPageIndex = e.NewPageIndex + 1; DataBind(); } </code></pre> <p>Thanks in advance for your help (: </p> <hr> <pre><code> public partial class _Event : System.Web.UI.Page { public HttpWebRequest req; public HttpWebResponse resp; public String link; public String line; public String stat; public String result; public DataTable data = new DataTable(); public DataTable clrdata = new DataTable(); protected void Page_Load(object sender, EventArgs e) { lblFiup.Text = ""; if (!Page.IsPostBack) { data.Columns.Add("URL", typeof(String)); data.Columns.Add("Status", typeof(String)); AddResultToGrid("", ""); // this is the only way i know how to do this, as of now... data.Rows[0].Delete(); Session["URLSessionData"] = data; BindGridView(); } } private void BindGridView() { gdvResults.DataSource = data; gdvResults.DataBind(); } 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.AllowPaging = true; gdvResults.DataBind(); Session["URLSessionData"] = data; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload