Solved

Paged listview - Set Active Page

Posted on 2009-04-07
4
680 Views
Last Modified: 2013-05-25
I have a listview that displays products. I have a datapager associated with the listview. I control the visibilty/population of product details by a query string value "prodID". I need to make sure that the right page is active when the page is loaded. So if prodID 10 exists on page 2 in the listview, then page 2 will be the active page when navigating to the URL (with prodID in the query string). prodID is a datakey in the listview.
0
Comment
Question by:centdevs
[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
  • 2
4 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 24096655
i am attaching 2 links
one for list view functions
http://www.codeproject.com/KB/webforms/CompleteListView.aspx

and the other one for customized pagination
http://www.codedigest.com/Articles/ASPNET/100_Paging_in_ListView_in_ASPNet_35.aspx

HTH
Ragi
0
 
LVL 4

Accepted Solution

by:
kruegerste earned 500 total points
ID: 24096849
Just use the SetPageProperties method for the datepager control in your code behind, as such:

int startRowIndex = 0;
int prodID = 0;

//Get pageIndex from Query String
prodID = int.Parse(Request.QueryString["prodID"].ToString());

//Get the row to start the page
startRowIndex = prodID

DataPager1.SetPageProperties(startRowIndex, DataPager1.PageSize, true);
0
 

Author Comment

by:centdevs
ID: 24098040
Which event should this code go in kruegerste?  
0
 
LVL 4

Expert Comment

by:kruegerste
ID: 24098111
You could put this code in the Page_Load method, probably the most common.  Only on the initial load I believe, so you may find that you want to put it inside an If Then that checks whether you are hitting the Page_Load method on a postback or if it is the initial load.

You just need access to the DataPager control, so any method in the life cycle after the Load ViewState method.  Look up the asp.net page life cycle and it will become more clear of what is happening and how the page request is processed.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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-…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

705 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