Pagelist. Wrong paging

Vote:
 
Hi guys. I'm using Pagelist to display something on the page. I'm using paging, and when I manually set PagesPerPagingItem to fx. 2, 3 etc. It works. BUT! I want this to be a property on the pagetype, that the editor can use. I've then wrote a function in my codebehind that returns the value for PagesPerPagingItem. The function returns the correct number. and first time view of the page, it displays the correct amount of items on the page. but when I go to second page, I get all the items listed. This is only an issue when the PagesPerPagingItem is "dynamic", although the function only runs 1 time, and returns the correct value. What might be the problem? /Savo
#13154
Aug 13, 2007 12:10
Vote:
 
Are you setting the value inside a if(!IsPostBack) block by any chance? If so take it out and set the value on page load all the time. Otherwise if that isn't the problem, can you post any example of your code up so we might be able to see what the issue is?
#15478
Aug 13, 2007 20:33
Vote:
 

I have a similar problem.

 

I have a drop down list that filters the results on a PageList. Pagination is on but when I click on one of the page numbers, the filter is ignored and I get all of the records and a new pagination range.

I tried setting a number for the PagesPerPaginItem as indicated above, but the problem persists.

Any ideas on how to resolve this?

 

    <div class="form-contacts">
        <asp:Label runat="server" AssociatedControlID="regionsList">View contacts by region:</asp:Label>
        <asp:DropDownList ID="regionsList" runat="server"  ValidationGroup="RegionSelect">
            <asp:ListItem Value="">Please select</asp:ListItem>
        </asp:DropDownList>
        <asp:ImageButton runat="server" ID="regionFilter" AlternateText="go" ImageUrl="/images/button_go.gif"
            ValidationGroup="RegionSelect" />
    </div>
    
    <EPiServer:PageList SortOrder="Alphabetical" ID="Contacts" runat="server" PagesPerPagingItem='<%# CurrentPage["ContactsCount"] %>' Paging="true">
        <ItemTemplate>
            <div class="contacts">
                <h2 class="heading-three"><%# Container.CurrentPage.PageName %></h2>
                <h3><%# Container.CurrentPage["JobTitle"] %></h3>
                
                <div class="clear">
                <img runat="server" height="105" width="93" class="framed" alt="<%# Container.CurrentPage.PageName %>"
                    src='<%# Container.CurrentPage["Image"]%>' visible='<%# !String.IsNullOrEmpty(Container.CurrentPage["Image"] as string) %>' />
                <div class="biogText">
                    <%# Container.CurrentPage["Biography"]%>
                </div>
                </div>
                
                <ul>
                    <li class="first">Email: <a href='mailto:<%# Container.CurrentPage["EmailAddress"]%>'>
                        <%# Container.CurrentPage["EmailAddress"]%></a></li>
                    <li>Phone:
                        <%# Container.CurrentPage["PhoneNumber"]%></li>
                    <li class="last">
                        <EPiServer:Property runat="server" ID="bloglink" PropertyName='BlogPage' PageLink='<%# Container.CurrentPage.PageLink%>' />
                    </li>
                </ul>
            </div>
        </ItemTemplate>
    </EPiServer:PageList>

 

 

#26616
Dec 12, 2008 18:08
Vote:
 

My very resourceful colleague referred me to the following article that might have all the answers.

http://aspnet.4guysfromrolla.com/articles/092904-1.aspx 

Here's an excerpt:

Understanding the Page Lifecycle


As page developers, we often think about ASP.NET Web pages consisting of two distinct portions: an HTML portion and a code-behind class. However, behind the scenes, when an ASP.NET Web page is requested for the first time (or for the first time after the page has changed) the HTML portion is autogenerated into a class from which the code-behind class is derived from. In essence, an ASP.NET Web page is represented, then, as a single class. Whenever an ASP.NET page is requested from the Web server, the corresponding page's class is instantiated and its ProcessRequest() method is invoked. This method kicks off the page lifecycle. The page lifecycle is a sequence of stages that the ASP.NET page's corresponding class progresses through. The end goal of the lifecycle is to generate the page's appropriate markup, which is then sent back to the requesting browser.

The page lifecycle is composed of a number of steps, the following ones being the ones of interest for this article:

1. Instantiation,
2. Initialization,
3. Load View State,
4. Load,
5. Save View State

The first stage if the page lifecycle is called Instantiation, and in this stage the page's control hierarchy is created. The control hierarchy is the hierarchy of server controls that exist in the page. Typically this includes an HtmlForm (the

), numerous LiteralControls (static HTML content in the page's HTML portion is represented as LiteralControls in the hierarchy), and the Web controls you added to the page's HTML portion. The control hierarchy is created by the autogenerated class. Since every time an ASP.NET page is requested, be it the first time or on a subsequent postback, the page class is reinstantiated and reiterates its lifecycle, each request causes the control hierarchy to be rebuilt from scratch in the Instantiation stage. More...

 

 

#26639
Dec 15, 2008 11:48
Vote:
 

Introduction


As I've written about in two previous articles here on 4Guys - Dynamic Controls in ASP.NET and Working with Dynamically Created Controls - ASP.NET makes it easy to programmatically add Web controls. Armed with this capability, you can offer a truly customized experience for your users. For example, your site might load particular navigational elements as user controls, based upon the logged on user's preferences. Or when collecting information from your users, you might display different input fields prompting for different data based on the user's age, location, gender, and so on.

One of the main challenges with working with dynamically added controls is that these controls must be programmatically added on each postback. That is, you can't just load these controls on the first page load, and then not reload them on subsequent postbacks. Failure to explicitly add the controls on each postback will cause the controls to literally disappear on postbacks. To further complicate things, the point in the page's lifecycle when dynamic controls are added is important if you want to maintain changed values across postback. For example, imagine you had a Web page that displayed a series of input form fields based on the user visiting the page. The idea here would be to allow the visitor enter some values into these custom input form fields, and then submit the form, having the data saved. If the dynamic Web controls are not added at the correct time in the page's lifecycle, the values entered by the visitor will be lost on postback.

In this article we will examine how to add dynamic Web controls to a page in such a manner that you will not need to worry about losing form field values on postback. Specifically, we'll look at how to create a page whose form fields are dependent upon the user visiting the page, and how this user can enter their data into these form fields and have it saved on form submission. Since this article builds upon concepts discussed earlier, please make sure you have read both Dynamic Controls in ASP.NET and Working with Dynamically Created Controls before tackling this article.

#26640
Dec 15, 2008 11:49
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.