Beispiel #1
0
 protected void btnEliminar_Click(object sender, EventArgs e)
 {
     foreach (GridViewRow row in gvAlbums.Rows)
     {
         if (txtID.Text == row.Cells[0].Text)
         {
             daoAlbum.eliminar(Int32.Parse(txtID.Text));
             gvAlbums.DataSource = daoAlbum.obtenerTodos();
             gvAlbums.DataBind();
         }
     }
 }
Beispiel #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     daoAlbum            = new DaoAlbum();
     gvAlbums.DataSource = daoAlbum.obtenerTodos();
     gvAlbums.DataBind();
 }
        private void chargeData()
        {
            albums = daoAlbum.obtenerTodos();
            HtmlGenericControl div;
            HtmlImage          image;
            HtmlGenericControl h4;
            HtmlGenericControl span;
            HtmlAnchor         buttonEdit;
            HtmlAnchor         buttonDelete;
            HtmlGenericControl iControl;

            for (int i = 0; i < albums.Count; i++)
            {
                div    = new HtmlGenericControl("DIV");
                div.ID = "card" + albums[i].idAlbum;
                div.Attributes["class"] = "card";

                image     = new HtmlImage();
                image.Src = "../../Recursos/Imagenes/Portadas/" + albums[i].Portada;
                div.Controls.Add(image);

                h4           = new HtmlGenericControl("H4");
                h4.InnerText = albums[i].Titulo;
                div.Controls.Add(h4);

                canciones = daoCancion.MostrarCancionesPorAlbum(albums[i].idAlbum);

                for (int j = 0; j < canciones.Count; j++)
                {
                    span           = new HtmlGenericControl("SPAN");
                    span.InnerText = canciones[j].Nombre;
                    div.Controls.Add(span);
                }

                buttonEdit                             = new HtmlAnchor();
                buttonEdit.ID                          = "btnEdit" + albums[i].idAlbum;
                buttonEdit.ServerClick                += new System.EventHandler(this.buttonsCard_click);
                buttonEdit.Attributes["runat"]         = "server";
                buttonEdit.Attributes["onserverclick"] = "buttonsCard_click";
                buttonEdit.Attributes["class"]         = "edit";

                iControl = new HtmlGenericControl("I");
                iControl.Attributes["class"] = "material-icons";
                iControl.InnerText           = "create";
                buttonEdit.Controls.Add(iControl);
                div.Controls.Add(buttonEdit);

                buttonDelete                             = new HtmlAnchor();
                buttonDelete.ServerClick                += new System.EventHandler(this.buttonsCard_click);
                buttonDelete.ID                          = "btnDelete" + albums[i].idAlbum;
                buttonDelete.Attributes["runat"]         = "server";
                buttonDelete.Attributes["onserverclick"] = "buttonsCard_click";
                buttonDelete.Attributes["class"]         = "delete";

                iControl = new HtmlGenericControl("I");
                iControl.Attributes["class"] = "material-icons";
                iControl.InnerText           = "delete";
                buttonDelete.Controls.Add(iControl);
                div.Controls.Add(buttonDelete);

                albumContainer.Controls.Add(div);
            }
        }