Solved

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

Posted on 2008-06-17
1
226 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

737 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