Use this JavaScript example to populate a drop down. Call it from another dropdown onchange event:
<script type="text/javascript">
function populateDD2() {
var dd1 = document.getElementById('<%=DD1.ClientID %>');
var dd2 = document.getElementById('<%=DD2.ClientID %>');
if (dd1.value == "Yes") {
var options = ["Option 1", "Option 2", "Option 3"];
for (var i = 0; i < options.length; i++) {
var opt = document.createElement("option");
opt.value = i;
opt.innerHTML = options[i];
dd2.appendChild(opt);
}
}
else {
dd2.options = null;// Or whatever else you might want to do.
}
}
</script>
Controls:
<asp:DropDownList runat="server" ID="DD1" onchange="populateDD2()">
<asp:ListItem Text="- Select -"></asp:ListItem>
<asp:ListItem Text="Yes"></asp:ListItem>
<asp:ListItem Text="No"></asp:ListItem>
</asp:DropDownList>
<asp:DropDownList runat="server" ID="DD2">
</asp:DropDownList>