3

I have a ListView control as follows (for posting here I've removed the values from my ItemTemplate):

<asp:ListView ID="ListView1" runat="server" DataSourceID="MyDataSource">
  <LayoutTemplate>
     <div id="requests" runat="server">
        <asp:Panel runat="server" id="itemPlaceholder"></asp:Panel>
     </div>
     <asp:DataPager runat="server" ID="DataPager" PageSize="3">
        <Fields>
            <asp:NumericPagerField ButtonCount="10" PreviousPageText="<--" NextPageText="-->" />
        </Fields>
     </asp:DataPager>
  </LayoutTemplate>
  <ItemTemplate>
     <div ID="itemPlaceholder" class="request" runat="server">
        <asp:LinkButton ID="button" runat="server" Text='...' CommandName="..." 
                CommandArgument='...' OnClick="..."
                style="...">
        </asp:LinkButton> -  
     </div>
  </ItemTemplate>
</asp:ListView>

This ListView exists as a user control (.ascx), which I've embedded into an ASPX web page.

As I expect, when the web page loads, for a list of 9 items, I get 3 pages of 3 items.

When I click to go to the next page, the page loads the next set of items correctly... but only for a brief second. Then a strange thing happens. The page embeds a copy of itself inside the page 6 times, each one of them underneath one of the fields on the form inside the page.

If I then attempt to go to the next or previous page, an ASP.NET server error appears:

The state information is invalid for this page and might be corrupted.

In the stack trace, it shows the following errors:

FormatException: The input is not a valid Base-64 string as it contains a non-base character, more than two padding characters, or a non-white space character among the padding characters.

ViewStateException: Invalid viewstate.

I was able to replicate this on both my browsers, IE8 and Chrome.

1
  • Looks that problem is in databinding. Please, provide a server code and data source code. Jun 12, 2015 at 13:46

1 Answer 1

0

you use listview event OnPagePropertiesChanging

like this

 <asp:ListView ID="lvCustomers" runat="server"   GroupPlaceholderID="groupPlaceHolder1"
ItemPlaceholderID="itemPlaceHolder1"    OnPagePropertiesChanging="OnPagePropertiesChanging">

in aspx.cs

protected void OnPagePropertiesChanging(object sender,PagePropertiesChangingEventArgs e)
{
    (lvCustomers.FindControl("DataPager1") as  DataPager).SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
this.BindListView();
}

BindListView() is method for binding list view

visit this link for example

i hope it's helpfull

1
  • it's work when your data binding is correct....give some code so I will give proper solution thanks Aug 12, 2015 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.