3
Reply

Adding child control to dropdownlist control

soumya p n

soumya p n

Apr 1 2008 8:07 AM
8.5k
Hello,
I need to add child control(a textbox) based on the selected value of the dropdown list.I have done something like
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if(DropDownList1.SelectedIndex==4)
            {
                TextBox txt = new TextBox();
                DropDownList1.Controls.Add(txt);
            }
        }
The above code gives the error saying,
'System.Web.UI.WebControls.DropDownList' does not allow child controls.
Any Help..?????

Thanks

Regards,
Soumya

Answers (3)