Hello all
I am trying to add the total of the items in my listbox
i have done this with my checkboxlist and it works no problem. When i try to add the total of my products in listbox i get 0.
<div id="available">
<asp:ListBox runat="server" ID="AvailableProducts" Height="500px" Width="300px" >
</asp:ListBox> <br />
<asp:Button runat="server" ID="addProduct" Text=">>" Width="75px" OnClick="addProduct_Click1" />
</div>
protected void Page_PreInit(object sender, EventArgs e) {
List<Product> products = CreateData.MakeProducts();
foreach (Product p in products) {
AvailableProducts.Items.Add(new ListItem(p.Name, Convert.ToString(p.Price)));
} } protected void addProduct_Click1(object sender, EventArgs e)
{ double total = 0;
while (AvailableProducts.Items.Count > 0 && AvailableProducts.SelectedItem != null)
{ ListItem li = AvailableProducts.SelectedItem;
li.Selected = false; ShoppingCart.Items.Add(li);
AvailableProducts.Items.Remove(li); }
foreach (ListItem i in ShoppingCart.Items) {
if (i.Selected) {
total += double.Parse(i.Value); } }
lbltotal.Text = total.ToString(); }
Another thing i am trying to do with this project is.
create a arraylist or list of product names and send them them to my exit.aspx so i can show the selected products at the exit page.
I used a Response.Redirect() to make a variable of customer status and pass it page to page I have it working for only the first page