Hi,
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 ?