Solved

Paged listview - Set Active Page

Posted on 2009-04-07
4
677 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

17 Experts available now in Live!

Get 1:1 Help Now