protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CadEstado oCadEstado = new CadEstado();
                lista = oCadEstado.consultarTodos();

                cboEstado.DataTextField = "sigla";
                cboEstado.DataValueField = "id";
                cboEstado.DataSource = lista;
                cboEstado.DataMember = "Tabela";
                cboEstado.DataBind();
                cboEstado.Items.Insert(0,"Selecione");
                cboEstado.SelectedIndex = 0 ;

                CadCidade oCadCidade = new CadCidade();
                lista = oCadCidade.consultarTodos();

                if (lista != null)
                {
                    gdvCadCidade.DataSource = lista;
                    gdvCadCidade.DataMember = "Tabela";
                    gdvCadCidade.DataBind();
                }
            }
        }
        protected void btnInserir_Click(object sender, EventArgs e)
        {
            if (cboEstado.SelectedValue.Equals(0))
            {

            }
            else
            {
                CadCidade objCadCidade = new CadCidade();
                objCadCidade.inserir(cboEstado.SelectedValue, txtcidade.Text);
                Response.Redirect(Request.RawUrl);
            }
        }
        private void carregarTabelaDataSet()
        {
            CadCidade objListarTodasCidades = new CadCidade();
            DataSet dtListarTodosFilmes = objListarTodasCidades.consultarTodos();

            for (int linha = 0; linha <= dtListarTodosFilmes.Tables["Tabela"].Rows.Count - 1; linha++)
            {
                TableRow tRow = new TableRow();
                tblCidades.Rows.Add(tRow);

                for (int coluna = 0; coluna <= 3; coluna++)
                {
                    TableCell tCell = new TableCell();
                    tCell.Text = Convert.ToString(dtListarTodosFilmes.Tables["Tabela"].Rows[linha][coluna]);
                    tRow.Cells.Add(tCell);
                }
            }
        }
 protected void btnApagar_Click(object sender, EventArgs e)
 {
     CadCidade objCadCidade = new CadCidade();
     objCadCidade.apagar(txtidCadCidade.Text, txtcidade.Text);
     Response.Redirect(Request.RawUrl);
 }
 protected void btnAlterar_Click(object sender, EventArgs e)
 {
     CadCidade objCadCidade = new CadCidade();
     objCadCidade.alterar(cboEstado.SelectedValue, txtcidade.Text, txtidCadCidade.Text);
     Response.Redirect(Request.RawUrl);
 }