protected void DropDownUf_SelectedIndexChanged(object sender, EventArgs e) { try { bd = new ProjectContext(); string UF = DropDownUf.SelectedItem.ToString(); var municipios = (from mun in bd.MUNICIPIOs where mun.UF == UF select mun.NOME).ToList(); DropDownCidade.DataSource = municipios; DropDownCidade.DataBind(); } catch (Exception) { throw; } }
//PageLoard da pagina #region Page_Load protected void Page_Load(object sender, EventArgs e) { funcaoJS(); if (!Page.IsPostBack) { bd = new ProjectContext(); var uf = (from estados in bd.ESTADOS select estados.NM_SIGLA).ToList(); DropDownUf.DataSource = uf; DropDownUf.DataBind(); string UF = DropDownUf.SelectedItem.ToString(); var municipios = (from mun in bd.MUNICIPIOs where mun.UF == UF select mun.NOME).ToList(); DropDownCidade.DataSource = municipios; DropDownCidade.DataBind(); } }