Click here to Skip to main content
12,957,526 members (59,996 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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" 
 <pagersettings firstpagetext="First" lastpagetext="Last">
     Mode="NextPreviousFirstLast" NextPageText="Next" PageButtonCount="4" 
     PreviousPageText="Previous" />


The C# code is:
protected void Page_Load(object sender, EventArgs e)
    if (!IsPostBack)
protected void Button_ReadFile_Click(object sender, EventArgs e)

public void bindGridView()
    if (FileUpload_StaffInfo.HasFile)
        string InfoFile_Name = Server.MapPath(InfoFileDirectory) + FileUpload_StaffInfo.FileName;
        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;

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?
Posted 11-Oct-12 5:23am
Updated 11-Oct-12 5:26am
AshishChaudha 12-Oct-12 0:45am
Please have a look on your code of onpageindexchanging="GridView_NewStaff_PageIndexChanging"...
@AmitGajjar 12-Oct-12 4:34am
Is your problem resolved ?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I can see PageIndexChangingEvent in your HTML( onpageindexchanging="GridView_NewStaff_PageIndexChanging"), but you have not listed the code for this event. Please post the code for this event because the logic for paging has to be written there.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,994
CHill60 3,550
Maciej Los 3,312
ppolymorphe 2,170
Jochen Arndt 1,973

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 12 Oct 2012
Copyright © CodeProject, 1999-2017
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