protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var dd = e.Row.FindControl("ddlSala") as DropDownList; if (dd != null) { DataTable Salas = new BLL.SalasBLL().Consultar(); dd.DataSource = Salas; dd.DataValueField = "Id"; dd.DataTextField = "Ubicacion"; dd.DataBind(); dd.SelectedValue = (e.Row.FindControl("lblIdSala") as Label).Text; } var ddP = e.Row.FindControl("ddlPelicula") as DropDownList; if (ddP != null) { DataTable Peliculas = new BLL.PeliculaBLL().Consultar(); ddP.DataSource = Peliculas; ddP.DataValueField = "Id"; ddP.DataTextField = "Nombre"; ddP.DataBind(); ddP.SelectedValue = (e.Row.FindControl("lblIdPelicula") as Label).Text; } } }
private void CargarGrid() { DataTable Cargos = new BLL.SalasBLL().Consultar(); GridView1.DataSource = Cargos; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable Pelicula = new BLL.PeliculaBLL().Consultar(); ddlPelicula.DataSource = Pelicula; ddlPelicula.DataValueField = "Id"; ddlPelicula.DataTextField = "Nombre"; ddlPelicula.DataBind(); DataTable Sala = new BLL.SalasBLL().Consultar(); ddlSala.DataSource = Sala; ddlSala.DataValueField = "Id"; ddlSala.DataTextField = "Ubicacion"; ddlSala.DataBind(); } }