Solved

Paged listview - Set Active Page

Posted on 2009-04-07
4
676 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
Comment Utility
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
Comment Utility
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
Comment Utility
Which event should this code go in kruegerste?  
0
 
LVL 4

Expert Comment

by:kruegerste
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

16 Experts available now in Live!

Get 1:1 Help Now