Hi ,
Check this
Dropdownlist[
^]
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DropDownList1.Items.Add("select");
DropDownList1.Items.Add("Animal");
DropDownList1.Items.Add("Vehicle");
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex == 1)
{
DropDownList2.Items.Clear();
DropDownList2.Visible = true;
DropDownList2.Items.Add("cat");
}
else if(DropDownList1.SelectedIndex == 2)
{
DropDownList2.Items.Clear();
DropDownList2.Visible = true;
DropDownList2.Items.Add("car");
}
else if (DropDownList1.SelectedIndex == 0)
{
DropDownList2.Visible = false;
DropDownList2.Items.Clear();
}
}
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server" Visible="False">
</asp:DropDownList>
</div>
Best Regards
M.Mitwalli