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 723929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:09:51+00:00 2026-05-14T06:09:51+00:00

What I’m trying to do is iterate through a repeater and read some controls

  • 0

What I’m trying to do is iterate through a repeater and read some controls values:

   foreach (RepeaterItem iter in TablePanier.Items)
    {
        string guid = ((HiddenField)iter.FindControl("guid")).Value.ToString();

        // nombre exemplaires du livre

        int nbExemplaires = int.Parse(((System.Web.UI.WebControls.TextBox)iter.FindControl("txtNbExemplaires")).Text.ToString());

    }

As you can see, I have a HiddenValue and a TextBox. Unfortunately this isn’t working, the values are not read correctly.

What’s wrong?

Thank you!

EDIT:
Here is the entire code of the form:

public partial class Panier : System.Web.UI.Page
{
    Bussiness.Manager _manager = new Bussiness.Manager("MSSQLSERVER");
    IEnumerable<Bussiness.iPanier> _paniers;
    CurrencyConvertor _currencyConvertor = new CurrencyConvertor();
    Bussiness.iCommande _commande;
    int  idPanier;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["login"] != null)
        {
            Security security = new Security();
           _paniers = _manager.chargerPannierUtilisateur(Session["login"].ToString());

            foreach (Bussiness.iPanier p in _paniers)
            {
                idPanier = p.id;
                TablePanier.DataSource = p.Livres;
                TablePanier.DataBind();
            }
        }

        else
        {
            Response.Redirect("~/Accueil.aspx");
        }
    }
    protected void btnCommande_Click(object sender, EventArgs e)
    {


        foreach (RepeaterItem iter in TablePanier.Items)
        {
            // id livre courant
            if (iter.ItemType == ListItemType.Item || iter.ItemType == ListItemType.AlternatingItem)
            {
                string guid = ((HiddenField)iter.FindControl("guid")).Value.ToString();
                int nbExemplaires = int.Parse(((System.Web.UI.WebControls.TextBox)iter.FindControl("txtNbExemplaires")).Text.ToString());

            }
        }
    }
}

As you can see, the repeater is bound at the constructor level. And I’m trying to read the data when an event occur on a button of the page.

Any idea ?

  • 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-14T06:09:52+00:00Added an answer on May 14, 2026 at 6:09 am

    A few things to check:

    • the repeater is bound in Page_Load on both the intial request and on postback. So when a button click posts the page, the repeater gets reloaded with the original data. Anything entered by the user is lost. Is this what you want? If not, use the IsPostBack property to load it on the GET request only.

    • if Session[“login”] is null, your repeater will not get loaded – I presume you have checked this?

    • in your posted code, you are not doing anything with the values you are trying to get from the repeater controls. Is this because there is additional code not shown?

    • Have you used the debugger to inspect the the controls found by FindControl to make sure they exist and they are what you think they are?

    • when you say ‘the values are not read”, do you mean you get null values? Empty strings?

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

Sidebar

Related Questions

No related questions found

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.