In one of my form there were two Dropdown fields. The second dropdown has to be populated from the database, dynamically from the selection of first dropdown.
Any help is appreciated.
In one of my form there were two Dropdown fields. The second dropdown has to be populated from the database, dynamically from the selection of first dropdown.
Any help is appreciated.
In the SelectedIndexChanged event of the first DropDownList, add code to populate the second DropDownList based on the selected value of the first list
Like this:
<asp:DropDownList runat="server" ID="from" AutoPostBack="true" CausesValidation="false" OnSelectedIndexChanged="from_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList runat="server" ID="to" />
protected void from_SelectedIndexChanged(object sender, EventArgs e)
{
var selectedValue = this.from.SelectedValue;
this.to.DataSource = /*get the data of the second list based on: selectedValue*/;
this.to.DataBind();
}