Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now