soumya p n

soumya p n

  • NA
  • 41
  • 0

Adding child control to dropdownlist control

Apr 1 2008 8:07 AM
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)