DropDownList.SelectedIndexChanged not working after AutoPostBack

  • Thread starter Thread starter Donal
  • Start date Start date
D

Donal

I have 3 related dropdowns. When the 1st is changed, the 2nd is
updated, and when the 2nd is changed, the 3rd is updated.

When i change the 1st dropdown (sites), the SelectedIndexChanged fires
and the 2nd dropdown (spaces) is updated. However, 'spaces' no longer
has a SelectedIndexChanged event. Where did it go to?

If I change 'spaces' (2nd dropdown) before it gets updated by the 1st
(sites), its SelectedIndexChanged is fired and the 3rd list (folders)
is updated. But now 'folders' does not have a SelectedIndexChanged
event! (I don't need it here, but just to show what's going on).

Seems when I rebuild the dropdown on Postback, it is not including the
SelectedIndexChanged.

Anyone any idea what I'm doing wrong?

I've included some of the code below.

Cheers.

-------------------------------------------------
private DropDownList sites;
private DropDownList spaces;
private DropDownList folders;

//CreateChildControls
sites = sitesDropDown(url);
Controls.Add(sites);
spaces = tsDropDown(url);
Controls.Add(spaces);

private DropDownList sitesDropDown(string folderURL)
{
DropDownList sites = new DropDownList();
sites.SelectedIndexChanged += new EventHandler(sites
_SelectedIndexChanged);
sites.AutoPostBack = true;
sites.DataSource = source;
sites.DataTextField = "Name";
sites.DataValueField = "Href";
sites.DataBind();

return sites;
}

private void sites_SelectedIndexChanged(object sender, EventArgs e)
{
spaces = tsDropDown(sites.SelectedValue);
}
 
Donal said:
spaces = tsDropDown(sites.SelectedValue);

What's tsDropDown and why are you setting your control equal to
whatever's returned by it?

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
Back
Top