[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Paged listview - Set Active Page

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

656 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