?
Solved

Paged listview - Set Active Page

Posted on 2009-04-07
4
Medium Priority
?
682 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 2000 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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month10 days, 19 hours left to enroll

770 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