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

  • SEARCH
  • Home
  • 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 6571747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:55:15+00:00 2026-05-25T14:55:15+00:00

I have a problem whereby the viewstate of a repeater i.e. the controls within

  • 0

I have a problem whereby the viewstate of a repeater i.e. the controls within the repeater are not maintaing their viewstate.

I have the following:

Repeater 1:

<asp:Repeater ID="rptImages" runat="server">
<ItemTemplate>
    <asp:LinkButton Text="Add" CommandName="Add" CommandArgument=<%# Eval("ID") %> runat="server" />
</ItemTemplate>
</asp:Repeater>

When the link button is clicked the value of the CommandArgument is stored in a hidden field on the page.

Upon postback I can’t get the value of the hidden field until the prerender event handler has loaded. So in my prerender event I grab the value of the hidden field and store it in a List property, like so:

if (!string.IsNullOrEmpty(this.SelectedImageIDsInput.Text)) {
        this.ImageList.Add(this.SelectedImageIDsInput.Text);
    }

And the List property looks like so:

public List<string> ImageList {
    get {
        if (this.ViewState["ImageList"] == null) {
            this.ViewState["ImageList"] = new List<string>();
        }
        return (List<string>)(this.ViewState["ImageList"]);
    }
    set { this.ViewState["ImageString"] = value; }
}

Once I have stored the value into my List property I bind my second repeater (again within the prerender event):

this.rptSelectedImages.DataSource = this.LightBoxControl.ImageList;
this.rptSelectedImages.DataBind();

The second repeater has a dropdownlist and a textbox within it. The problem is that the viewstate of these child controls is not maintained. I presume it is because with each postback I am rebinding the repeater, therefore it is rebuilt. What I don’t know is how I can possibly get round this? The ImageList property is only updated upon a postback, so I obviously have to rebind the repeater with each postback – how else can it be done?

Any help would be greatly appreciated.

Thanks
Al

  • 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-25T14:55:16+00:00Added an answer on May 25, 2026 at 2:55 pm

    If you are rebinding the repeater, you need to do it on Init before the ViewState is loaded.

    You should also check the IsPostback flag and only Bind the repeater when the page is not posted back.

    To clarify if your second repeater is bound on PreRender then ViewState cannot be used to persist the controls, because they simply don’t exist when ViewState is loaded – after Init, and before PreLoad.

    You either need to continue binding on every postback, or store or list in Session so that you have access to the list to bind once on Init, (or on change).

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

Sidebar

Related Questions

I have this problem whereby, i have created a user defined function within php.
I have a problem whereby a vector of pointers does not seem to be
I have a strange problem whereby the ValidationSummary is not being displayed. However, the
I have a seemingly simple problem whereby I wish to reconcile two lists so
I have encountered a problem twice now whereby a producer thread produces N work
I have what is likely a simple problem, whereby I am trying to get
I have problem SIMILAR to preventing form data reposting, but not quite the same
I have a problem whereby I have set the body font-size to 11px, but
We currently have a problem whereby on our stage servers, links that exist on
iPhone Safari seems to have some sort of problem whereby a page with css

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.