public ActionResult Editar(int id) { if (TempData["mensaje"] != null) { ViewBag.mensaje = TempData["mensaje"].ToString(); } Empleado empleado = empleadoDatos.Get(id); if (empleado == null) { return(HttpNotFound()); } ViewBag.profesiones = profesionDatos.List(""); return(View(empleado)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlProfesiones.DataSource = profesionDatos.List(""); ddlProfesiones.DataBind(); int id = Convert.ToInt32(Request.QueryString["id"]); Empleado empleado = empleadoDatos.Get(id); hfID.Value = empleado.id.ToString(); txtNombre.Text = empleado.nombre; txtDireccion.Text = empleado.direccion; txtTelefono.Text = empleado.telefono.ToString(); if (empleado.sexo == "Masculino") { rbMasculino.Checked = true; rbFemenino.Checked = false; } if (empleado.sexo == "Femenino") { rbMasculino.Checked = false; rbFemenino.Checked = true; } ddlProfesiones.SelectedValue = empleado.id_profesion.ToString(); if (Application["mensaje"] != null) { string mensaje = Application["mensaje"].ToString(); lblMensaje.Text = mensaje; Application["mensaje"] = ""; } } }