Click here to Skip to main content

daiwuju asked:

Open original thread
The HTML code of the GrdiView is:
-----------------------------------------------------------------------------------
<asp:GridView ID="GridView_NewStaff" runat="server" AutoGenerateColumns="False" 
 CellPadding="4" Font-Size="Small" ForeColor="#333333" AllowPaging="True" 
 AllowSorting="True" onpageindexchanging="GridView_NewStaff_PageIndexChanging" 
 PageSize="20">
 <pagersettings firstpagetext="First" lastpagetext="Last">
     Mode="NextPreviousFirstLast" NextPageText="Next" PageButtonCount="4" 
     PreviousPageText="Previous" />
	 <columns>......
-----------------------------------------------------------------------------------
 
The C# code is:
-----------------------------------------------------------------------------------
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        bindGridView();
    }
}
 
protected void Button_ReadFile_Click(object sender, EventArgs e)
{
	bindGridView();
}
 

public void bindGridView()
{
    if (FileUpload_StaffInfo.HasFile)
    {
        string InfoFile_Name = Server.MapPath(InfoFileDirectory) + FileUpload_StaffInfo.FileName;
        FileUpload_StaffInfo.SaveAs(InfoFile_Name);
 
        dataTable_Excel = new DataTable();
 
        if (InfoFile_Name.EndsWith(".xlsx"))//Read Excel2007-2010 format file
        {
            StaffExcelXML StaffNewXML = new StaffExcelXML();
	    StaffNewXML.ExcelInput(InfoFile_Name, ref dataTable_Excel)
        }
        else if (InfoFile_Name.EndsWith(".xls"))//Read Excel1997-2003 format file
        {
            StaffXLS StaffNewXLS = new StaffXLS();
	    StaffNewXLS.ExcelInput(InfoFile_Name, ref dataTable_Excel);
        }
 
        GridView_NewStaff.DataSource = dataTable_Excel;
        GridView_NewStaff.DataBind();
    }
}
-----------------------------------------------------------------------------------
Everytime after clicking the Next, or the Previous, or the First, or the Last, it always shows the first page's data. Could anyone help me with this?
Tags: C#, ASP.NET

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100