Solved

Gridview keeping track of previous page number and applying it on new selection showing previous page number.

Posted on 2008-06-17
1
227 Views
Last Modified: 2013-12-16
I have a page that display alphabets A-Z.
[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]
when the page loads, it displays data with surname that starts with A. You can click on the other alphabets to display accordingly

1. if  i select "B"  and the number of  pages is  3 on the gridview and i click on page 3,
   I then click on another alphabet "V" that has 3 pages too,my grid shows
   records from page 3 and makes page 3 active. I will have to go and click on page 1
 
   whenever i click on any alphabet i want it to start on page 1 and not
   any other page and page 1 should be the active page not tracking my  
   previous page numbers.


Thanks.

Here is the code handling this. I will post more code as needed.
 
protected void sdgridview_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        try
        {
            //right here
            sdgridview.DataSource = SortDataTable(sdgridview.DataSource as DataTable, true);
            sdgridview.PageIndex = e.NewPageIndex;
            sdgridview.DataBind();                 
        }
        catch (Exception ex)
        {
            Response.Redirect("Error.aspx");
        }
    }

Open in new window

0
Comment
Question by:Sirdots
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 37

Accepted Solution

by:
samtran0331 earned 500 total points
ID: 21809654
when you change letters, I assume you rebind the grid? if yes, when the grid rebinds, try setting PageIndex = 0
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question