private void LlenarElementos() { try { Elemento_AtributoBC objElemento_AtributoBC = new Elemento_AtributoBC(); List<Elemento_AtributoBE> lstElemento_AtributoBE = new List<Elemento_AtributoBE>(); try { lstElemento_AtributoBE = objElemento_AtributoBC.Get_Elemento_Atributo_Atributo(Convert.ToInt32(ViewState["ID_ATRIBUTO"])); if (lstElemento_AtributoBE != null) { gvElementos.DataSource = lstElemento_AtributoBE; gvElementos.DataBind(); } else { lstElemento_AtributoBE = new List<Elemento_AtributoBE>(); lstElemento_AtributoBE.Add(new Elemento_AtributoBE()); gvElementos.DataSource = lstElemento_AtributoBE; gvElementos.DataBind(); int TotalColumns = gvElementos.Rows[0].Cells.Count; gvElementos.Rows[0].Cells.Clear(); gvElementos.Rows[0].Cells.Add(new TableCell()); gvElementos.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Left; gvElementos.Rows[0].Cells[0].ColumnSpan = TotalColumns; gvElementos.Rows[0].Cells[0].Text = "<center>[No se encontraron elementos]</center>"; } } catch (Exception) { throw; } } catch (Exception) { throw; } }
private void CrearAtributo(string atributo) { try { string[] atributos = atributo.Split(','); Panel pnl = new Panel(); pnl.ID = "pnl" + atributos[0]; pnl.CssClass = "pnl-atributo"; Label lblTitulo = new Label(); lblTitulo.Text = atributos[1]; lblTitulo.ID = "lblAtributo" + atributos[0]; pnl.Controls.Add(lblTitulo); ImageButton ibtnCancel = new ImageButton(); ibtnCancel.ID = "ibtnCancel" + atributos[0]; ibtnCancel.ImageUrl = "../images/cancel.png"; ibtnCancel.Click += ibtnCancel_Click; pnl.Controls.Add(ibtnCancel); Elemento_AtributoBC objElemento_AtributoBC = new Elemento_AtributoBC(); List <Elemento_AtributoBE> lstElemento_AtributoBE = new List <Elemento_AtributoBE>(); lstElemento_AtributoBE = objElemento_AtributoBC.Get_Elemento_Atributo_Atributo(Convert.ToInt32(atributos[0])); GridView gvElementoAtributo = new GridView(); gvElementoAtributo.ID = "gvElementoAtributo" + atributos[0]; gvElementoAtributo.CssClass = "gridview"; gvElementoAtributo.AlternatingRowStyle.CssClass = "alt"; gvElementoAtributo.PagerStyle.CssClass = "pgr"; gvElementoAtributo.AutoGenerateColumns = false; TemplateField tfCheck = new TemplateField(); gvElementoAtributo.Columns.Add(tfCheck); BoundField bfNombre = new BoundField(); bfNombre.DataField = "Nombre"; bfNombre.HeaderText = "Nombre"; gvElementoAtributo.Columns.Add(bfNombre); BoundField bfIdElemento = new BoundField(); bfIdElemento.DataField = "Id_Elemento_Atributo"; bfIdElemento.HeaderText = "Id_Elemento_Atributo"; bfIdElemento.Visible = false; gvElementoAtributo.Columns.Add(bfIdElemento); gvElementoAtributo.RowDataBound += gvElementoAtributo_RowDataBound; gvElementoAtributo.DataSource = lstElemento_AtributoBE; gvElementoAtributo.DataBind(); pnl.Controls.Add(gvElementoAtributo); pnlAtributos.Controls.Add(pnl); } catch (Exception) { throw; } }