So I've written a program where the number of letters of a city name from a drop down list are multiplied to a certain constant. However it doesn't update.
Here is the html:
<asp:DropDownList ID="Destinacii" runat="server" Height="20px" Width="76px" OnSelectedIndexChanged="Destinacii_SelectedIndexChanged"></asp:DropDownList>
Price: <asp:Label ID="Price" runat="server" Text="0"></asp:Label>
Here is the c# code:
protected void Destinacii_SelectedIndexChanged(object sender, EventArgs e)
{
string text = Destinacii.SelectedItem.Text;
int price = (2000 * text.Length);
Price.Text = price.ToString();
}
P.S. I've added the items in c#, not in the html.
From Why event not fired when I change selection on DropDownList?:
You need to set the
AutoPostBackproperty toTruein yourDropDownListlike so: