on this site
when dropdownlist contains only one item, when clicked it doesn’t cause a post back
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DropDownList1.Items.Add("a");
DropDownList2.Items.Add("a");
DropDownList2.Items.Add("b");
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Write(DropDownList1.Text);//does not work ????????????
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Write(DropDownList2.Text);
}
DropDownList1_SelectedIndexChanged will never trigger because you only have 1 item in DropDownList1, thus index will never be changed.
Updated
What you can do is add a null value to the dropdownlist1, like so