How to display in a form the next object of a collection?
- by user359706
I have a list of objects produced.
after click on next I want to display the next product in the form
my products list:
Private List listProduct;
listProduits = new List<Product>();
Product objProduit_1 = new Produit;
objProduct_1.ref = "001";
objProduct_1.article = "G900";
objProduct_1.quantity = 30;
listProducts.Add(objProduct_1);
ProductobjProduit_2 = new Product;
objProduct_2.ref = "002";
objProduct_2.article = "G900";
objProduct_2.quantity = 35;
listProduits.Add(objProduct_2);
in my asp page I have the following form:
<form id="formNF" runat="server">
<asp:TextBox ID="txtRef" runat="server"></asp:TextBox>
<asp:TextBox ID="txtArticle" runat="server"></asp:TextBox>
<asp:TextBox ID="txtQauntity" runat="server"></asp:TextBox>
<asp:Button ID="ButtonNext" runat="server" Text="Next product" OnClick="ButtonNext_Click"/>
</form>
In my code-behind:
protected void ButtonNext_Click(object sender, EventArgs e)
{
// I do not know how to retrieve the following product
// How to stop and continue after click on next button?
foreach (Product prd in listProduct){
txtRef.Text = prd.ref;
txtRef.Text = prd.article;
txtRef.Text = prd.quantity;
}
}
Thank you in advance.