Ok so the problem i am having is with a drop down list. the drop down list is supposed to output (Drinklabel) the selected value, it dose this but only the first in the list (the drop down list is generated by session variable).
I would like it so i could use the drop down list, select new value then have the label (Drinklabel) update itself.
*code bellow *
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Drinklabel.Text = "Your Chosen Beverage is A " + DropDownList1.SelectedValue.ToString() + " Drink.";
}
////////////////////////////////////////////////////////////
Full about page code
public partial class About : Page
{
protected void Page_Load(object sender, EventArgs e)
{
MyFruit = Session["Fruitname"] as List<string>;
//Create new, if null
if (MyFruit == null)
MyFruit = new List<string>();
DropDownList1.DataSource = MyFruit;
DropDownList1.DataBind();
}
public List<string> MyFruit { get; set; }
protected void ButtonCalculate_Click(object sender, EventArgs e)
{
decimal total = calculatePrice(DropDownList1.SelectedItem.Text,
TextBoxQuantity.Text.Trim());
LabelResult.Text = "You would like " + TextBoxQuantity.Text.Trim() +
DropDownList1.SelectedItem.Text + "(s) for a total of $" +
total.ToString();
}
private decimal calculatePrice(string p1, string p2)
{
throw new NotImplementedException();
}
private decimal calculatePrice(string fruitName, int quantity)
{
// Ask the database for the price of this particular piece of fruit by name
decimal costEach = GoToDatabaseAndGetPriceOfFruitByName(fruitName);
return costEach * quantity;
}
private decimal GoToDatabaseAndGetPriceOfFruitByName(string fruitName)
{
throw new NotImplementedException();
}
}