Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 541611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:21:38+00:00 2026-05-13T10:21:38+00:00

I am making a web site for my college project. The project is website

  • 0

I am making a web site for my college project.
The project is website thats gets everything from web service.
Can somebody tell whats going on, and how i fix it ?

On one of my pages i have ListView control to display product items, and Pager on same page.
On the first time page renderes fine and everything is displayed. When i click on nextPage on Pager, its reload page but doesn’t display second page, rather displays same data, if i push once more then i am gettin:

Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

My products page i quiet simple:

<asp:ListView ID="lv_ProductList" runat="server" DataKeyNames="product_id">
        <LayoutTemplate>
            <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
            <br />
            <br />
            <asp:DataPager ID="pageTopics" runat="server" PageSize="8" PagedControlID="lv_ProductList" >
                <Fields>
                    <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowPreviousPageButton="true" ShowNextPageButton="false" ButtonCssClass="span" />
                    <asp:NumericPagerField />
                    <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowPreviousPageButton="false" ShowNextPageButton="true" ShowLastPageButton="false" />
                </Fields>
           </asp:DataPager>
        </LayoutTemplate>
        <ItemTemplate>
            <div class="item">
                <img src="images/pic_1.jpg" width="91" height="105" alt="iPod" class="left" />
                <h3><a href="http://www.justwebtemplates.com"><%# Eval("product_name") %></a></h3>
                <p><%# Eval("product_desc").ToString().Substring(0,90) + "..." %> </p>
                <div><a href="http://www.freewebsitetemplates.com" class="details">details</a> <a href="http://www.freewebsitetemplates.com" class="addtocart">add to cart</a></div>
                <div class="divider"></div>
            </div>
        </ItemTemplate>
        <EmptyDataTemplate>No products found</EmptyDataTemplate>
        <EmptyItemTemplate>No products found</EmptyItemTemplate>
    </asp:ListView> 

And in the code behind i have:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            getProductsList();
        }
    }


    public void getProductsList()
    {
        Store.Service myProducts = new Store.Service();
        var products = myProducts.getProductList();

        lv_ProductList.DataSource = products;
        lv_ProductList.DataBind();
    }

and on the web service:

[WebMethod]
    public List<ws_product> getProductList()
    {
        using (DataClassesDataContext myProducts = new DataClassesDataContext())
        {

            var productList = from p in myProducts.ws_products
                              select p;

            return productList.ToList();
        }

}

Can somebody tell whats going on ?
Also if i take Pager outside the ListView, then i don’t get error, however if i click on the nextpage link it displays same set of data.

How do i fix it ?
Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:21:39+00:00Added an answer on May 13, 2026 at 10:21 am

    On your code behind add:

    protected void lds_Selecting(object sender, LinqDataSourceSelectEventArgs args)
    {
            Store.Service myProducts = new Store.Service();  
            args.Result  = myProducts.getProductList();     
    }
    

    Add asp:LinqDataSource to the page:

      <asp:LinqDataSource ID="lds" runat="server" OnSelecting="lds_Selecting" />
    
    
        <asp:ListView ID="lv_ProductList" runat="server" 
    DataKeyNames="product_id"   DataSourceID="lds">   
                <LayoutTemplate>   
                    <asp:PlaceHolder ID="itemPlaceholder" runat="server" />   
                    <br />   
                    <br />   
                    <asp:DataPager ID="pageTopics" runat="server" PageSize="8" PagedControlID="lv_ProductList" >   
                        <Fields>   
                            <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowPreviousPageButton="true" ShowNextPageButton="false" ButtonCssClass="span" />   
                            <asp:NumericPagerField />   
                            <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowPreviousPageButton="false" ShowNextPageButton="true" ShowLastPageButton="false" />   
                        </Fields>   
                   </asp:DataPager>   
                </LayoutTemplate>   
                <ItemTemplate>   
                    <div class="item">   
                        <img src="images/pic_1.jpg" width="91" height="105" alt="iPod" class="left" />   
                        <h3><a href="http://www.justwebtemplates.com"><%# Eval("product_name") %></a></h3>   
                        <p><%# Eval("product_desc").ToString().Substring(0,90) + "..." %> </p>   
                        <div><a href="http://www.freewebsitetemplates.com" class="details">details</a> <a href="http://www.freewebsitetemplates.com" class="addtocart">add to cart</a></div>   
                        <div class="divider"></div>   
                    </div>   
                </ItemTemplate>   
                <EmptyDataTemplate>No products found</EmptyDataTemplate>   
                <EmptyItemTemplate>No products found</EmptyItemTemplate>   
            </asp:ListView> 
    

    this should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've rewritten my family web site using JavaScript (JQuery) making Ajax calls to PHP
I was making a website for a music band, and i was wondering the
I am thinking about making a website with some fairly intense JavaScript/canvas usage and
I have a question about tables in MySQL. I'm currently making a website where
Right now I'm making an extremely simple website- about 5 pages. Question is if
I'm creating a website for my church and I'm having problems making it display
I am currently in the process of making a new ASP.net MVC website, and
I'm making my way through the early Data Access Tutorials on Microsoft's ASP.NET website
At my current job I've been working on making web apps with Java, Tapestry,
Does anyone have any good starting points for me when looking at making web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.