H
Harry
Hi,
Quick question for the clever ones out there!
- I have two dropdown lists on one page.
- They are getting values from a SQL databse.
- When a user select's a a value from the first dropdown the
"OnSelectedIndexChanged" is fired.
- This event updates a asp:label with a Value. (In this case a
decimal)
Problem is, I want the user to now select a value from the second
dropdown, but the first dropdown resets itself to the first value in
the dropdown list.
I have enabled "viewstate" to True, but this does not seem to make any
difference.
Has anyone got any ideas?
Thanks in advance
H
protected void Page_Load(Object Src, EventArgs E)
{
if (!IsPostBack);
****Extract *****
ddlCDs.DataSource = GetCDs.ExecuteReader();
ddlCDs.DataTextField = "Name" ;
ddlCDs.DataValueField = "Price";
ddlCDs.DataBind();
myConnection.Close();
lblPrice.Text = startprice.ToString();
}
protected void Drop_Change(Object Src, EventArgs E)
{
decimal TotalCost = Convert.ToDecimal(ddlCDs.SelectedItem.Value) +
Convert.ToDecimal(ddlDVDs.SelectedItem.Value);
lblPrice.Text = TotalCost.ToString();
}
**** Code from Page ****
<asp:dropdownlist ID="ddlCDs" CssClass="TextBoxes"
EnableViewState="true" DataTextFormatString="{0:c}"
OnSelectedIndexChanged="Drop_Change" AutoPostBack="true"
runat="server"></asp:dropdownlist>
<asp:dropdownlist ID="ddlDVDs" CssClass="TextBoxes"
EnableViewState="true" DataTextFormatString="{0:c}"
OnSelectedIndexChanged="Drop_Change" AutoPostBack="true"
runat="server"></asp:dropdownlist>
Quick question for the clever ones out there!
- I have two dropdown lists on one page.
- They are getting values from a SQL databse.
- When a user select's a a value from the first dropdown the
"OnSelectedIndexChanged" is fired.
- This event updates a asp:label with a Value. (In this case a
decimal)
Problem is, I want the user to now select a value from the second
dropdown, but the first dropdown resets itself to the first value in
the dropdown list.
I have enabled "viewstate" to True, but this does not seem to make any
difference.
Has anyone got any ideas?
Thanks in advance
H
protected void Page_Load(Object Src, EventArgs E)
{
if (!IsPostBack);
****Extract *****
ddlCDs.DataSource = GetCDs.ExecuteReader();
ddlCDs.DataTextField = "Name" ;
ddlCDs.DataValueField = "Price";
ddlCDs.DataBind();
myConnection.Close();
lblPrice.Text = startprice.ToString();
}
protected void Drop_Change(Object Src, EventArgs E)
{
decimal TotalCost = Convert.ToDecimal(ddlCDs.SelectedItem.Value) +
Convert.ToDecimal(ddlDVDs.SelectedItem.Value);
lblPrice.Text = TotalCost.ToString();
}
**** Code from Page ****
<asp:dropdownlist ID="ddlCDs" CssClass="TextBoxes"
EnableViewState="true" DataTextFormatString="{0:c}"
OnSelectedIndexChanged="Drop_Change" AutoPostBack="true"
runat="server"></asp:dropdownlist>
<asp:dropdownlist ID="ddlDVDs" CssClass="TextBoxes"
EnableViewState="true" DataTextFormatString="{0:c}"
OnSelectedIndexChanged="Drop_Change" AutoPostBack="true"
runat="server"></asp:dropdownlist>