void dd_SelectedIndexChanged(object sender, EventArgs e) { DropDownList dd = sender as DropDownList; if (dd.SelectedItem == null) return; m_ddTrigger = dd.ID; switch (dd.ID) { case "Dept": GroupsTableAdapter gta = new GroupsTableAdapter(); DropDownList dst = Panel1.FindControl("Group") as DropDownList; dst.DataSource = gta.GetGroupsByDeptId(new Guid(dd.SelectedValue)); dst.DataBind(); break; case "Group": TeamsTableAdapter tta = new TeamsTableAdapter(); dst = Panel1.FindControl("Team") as DropDownList; dst.DataSource = tta.GetTeamsByGroupId(new Guid(dd.SelectedValue)); dst.DataBind(); break; case "Team": break; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void dd_PreRender(object sender, EventArgs e) { return; // Clear Team in case the Group is empty... if (m_ddTrigger == "Group") { DropDownList dd = sender as DropDownList; if (dd.SelectedItem == null) { DropDownList dst = Panel1.FindControl("Team") as DropDownList; dst.Items.Clear(); } else { TeamsTableAdapter tta = new TeamsTableAdapter(); DropDownList dst = Panel1.FindControl("Team") as DropDownList; dst.DataSource = tta.GetTeamsByGroupId(new Guid(dd.SelectedValue)); dst.DataBind(); } } }