private void fillAreas(DropDownList combo, int c) { combo.Enabled = false; combo.Items.Clear(); combo.AppendDataBoundItems = true; combo.DataSource = (c == 0 ? psvm.getAreasByUnidad(Convert.ToInt32(ComboUnidad.SelectedItem.Value)) : psvm.getAreasByUnidad(Convert.ToInt32(cargo_comboUnidad.SelectedItem.Value))); combo.DataTextField = "ARE_NOM"; combo.DataValueField = "ARE_COD"; combo.DataBind(); if (combo.Items.Count > 0) { combo.Enabled = true; if (c == 0) { ComboArea_SelectedIndexChanged(ComboArea, null); } else { cargo_comboArea_SelectedIndexChanged(cargo_comboArea, null); } } else { combo.Enabled = false; if (c == 0) { combo.Items.Add(new ListItem("--Añadir--", "")); } else { combo.Items.Add(new ListItem("--Ninguno--", "")); } } }
private void fillAreas() { ComboArea.Enabled = false; ComboArea.Items.Clear(); ComboArea.AppendDataBoundItems = true; ComboArea.DataSource = psvm.getAreasByUnidad(Convert.ToInt32(comboUnidad.SelectedItem.Value)); ComboArea.DataTextField = "ARE_NOM"; ComboArea.DataValueField = "ARE_COD"; ComboArea.DataBind(); if (ComboArea.Items.Count > 0) { ComboArea.Enabled = true; ComboArea_SelectedIndexChanged(ComboArea, null); } else { ComboArea.Enabled = false; ComboArea.Items.Clear(); ComboArea.AppendDataBoundItems = true; ComboArea.Items.Add(new ListItem("--Ninguno--", "")); ComboArea.DataBind(); comboCargo.Enabled = false; comboCargo.Items.Clear(); comboCargo.AppendDataBoundItems = true; comboCargo.Items.Add(new ListItem("--Ninguno--", "")); comboCargo.DataBind(); } }