protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { GraduacaoController graduacaoController = new GraduacaoController(); txtGraduacao.DataSource = graduacaoController.ObterTodos(); txtGraduacao.DataTextField = "nomGra"; txtGraduacao.DataValueField = "codGra"; txtGraduacao.DataBind(); txtGraduacao.Items.Insert(0, new ListItem("", "0")); ExtraController extraController = new ExtraController(); txtUf.DataSource = extraController.listaEstado(); txtUf.DataTextField = "sigEst"; txtUf.DataValueField = "sigEst"; txtUf.DataBind(); txtUf.Items.Insert(0, new ListItem("", "0")); } catch { } } }
protected void txtUf_SelectedIndexChanged(object sender, EventArgs e) { txtUf.Focus(); try { if (txtUf.SelectedValue != "0") { txtCidade.Items.Clear(); ExtraController extraController = new ExtraController(); txtCidade.DataSource = extraController.listaCidade(txtUf.SelectedValue); txtCidade.DataTextField = "nomCid"; txtCidade.DataValueField = "nomCid"; txtCidade.DataBind(); txtCidade.Items.Insert(0, new ListItem("", "0")); } else { txtCidade.Items.Clear(); txtCidade.Items.Insert(0, new ListItem("Selecione um estado", "0")); txtCidade.Items.Insert(0, new ListItem("", "0")); } } catch { } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ExtraController extraController = new ExtraController(); txtUf.DataSource = extraController.listaEstado(); txtUf.DataTextField = "sigEst"; txtUf.DataValueField = "sigEst"; txtUf.DataBind(); txtUf.Items.Insert(0, new ListItem("", "0")); if (Session["cnpjEmp"] != null) { PreencheCampos(); txtCnpj.Enabled = false; btnExcluir.Visible = true; txtNome.Focus(); } } }