protected void BtnAtualizarUsuario(object sender, EventArgs e) { try { Aluno p = new Aluno(); p.Codigo = Convert.ToInt32(txtCodigo.Text); p.Nome = Convert.ToString(txtNome.Text); p.Data_Nasc = Convert.ToString(txtData_Nasc.Text); p.Idade = Convert.ToString(txtIdade.Text); p.Objetivo_Graduacao = Convert.ToString(txtObjetivo_Graduacao.Text); p.Genero = Convert.ToString(txtGenero.Text); AlunoDAL d = new AlunoDAL(); d.Atualizar(p); lblMemsagem.Text = "Aluno " + p.Nome + " Atualizado com Sucesso!"; txtCodigo.Text = string.Empty; txtNome.Text = string.Empty; txtData_Nasc.Text = string.Empty; txtIdade.Text = string.Empty; txtObjetivo_Graduacao.Text = string.Empty; txtGenero.Text = string.Empty; } catch (Exception ex) { lblMensagem.Text = ex.Message; } }
protected void gridAlunos_RowUpdating(object sender, GridViewUpdateEventArgs e) { int index = e.RowIndex; Label lblIdAluno = gridAlunos.Rows[index].FindControl("lblIdAluno") as Label; TextBox txtNomeAluno = gridAlunos.Rows[index].FindControl("txtNomeAluno") as TextBox; TextBox txtEmailAluno = gridAlunos.Rows[index].FindControl("txtEmailAluno") as TextBox; Aluno a = new Aluno(); a.IdAluno = Convert.ToInt32(lblIdAluno.Text); a.NomeAluno = Convert.ToString(txtNomeAluno.Text); a.EmailAluno = Convert.ToString(txtEmailAluno.Text); AlunoDAL aDAL = new AlunoDAL(); aDAL.Atualizar(a); gridAlunos.EditIndex = -1; CarregarGridView(); }