protected void DropDownListdepartamento_SelectedIndexChanged(object sender, EventArgs e) { try { DropDownListmunicipio.Items.Clear(); DropDownListmunicipio.Items.Add(new ListItem("Seleccione", "Seleccione")); munic.departamento_iddepartamento = Validar.validarselected(DropDownListdepartamento.SelectedValue); DropDownListmunicipio.DataSource = Validar.Consulta(munic.ConsultarMunicipioIdDepartamento(munic)); DropDownListmunicipio.DataTextField = "municipio"; DropDownListmunicipio.DataValueField = "idmunicipio"; DropDownListmunicipio.DataBind(); } catch (Exception ex) { textError.InnerHtml = ex.Message; Alerta.CssClass = "alert alert-error"; Alerta.Visible = true; } }
private void cargarMunicipios(string dat) { try { DropDownListmunicipio.Items.Clear(); DropDownListmunicipio.Items.Add(new ListItem("Seleccione", "Seleccione")); munic.departamento_iddepartamento = dat; DropDownListmunicipio.DataSource = Validar.Consulta(munic.ConsultarMunicipioIdDepartamento(munic)); DropDownListmunicipio.DataTextField = "municipio"; DropDownListmunicipio.DataValueField = "idmunicipio"; DropDownListmunicipio.SelectedValue = "1"; DropDownListmunicipio.DataBind(); } catch (Exception ex) { textError.InnerHtml = ex.Message; Alerta.CssClass = "alert alert-error"; Alerta.Visible = true; } }