protected void btnAgregar_Click(object sender, EventArgs e) { String Mensaje = new BLL.CargosBLL().CrearCargo(txtCargo.Text); CargarGrid(); lblEstado.Text = Mensaje; }
private void CargarGrid() { DataTable Cargos = new BLL.CargosBLL().ConsultarCargos(); GridView1.DataSource = Cargos; GridView1.DataBind(); }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var dd = e.Row.FindControl("ddlCargo") as DropDownList; if (dd != null) { DataTable Cargos = new BLL.CargosBLL().ConsultarCargos(); dd.DataSource = Cargos; dd.DataValueField = "ID"; dd.DataTextField = "Nombre"; dd.DataBind(); dd.SelectedValue = (e.Row.FindControl("lblIdCargo") as Label).Text; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable Cargos = new BLL.CargosBLL().ConsultarCargos(); ddlCargos.DataSource = Cargos; ddlCargos.DataValueField = "ID"; ddlCargos.DataTextField = "Nombre"; ddlCargos.DataBind(); txtNombre.Text = string.Empty; txtApellido.Text = string.Empty; txtIdentifiacion.Text = string.Empty; txtTelefono.Text = string.Empty; txtCelular.Text = string.Empty; txtDireccion.Text = string.Empty; txtLogin.Text = string.Empty; txtContrasena.Text = string.Empty; } }