protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "pay") { if (Session["Usuario"] != null) { //Busca una referencia al 'linkbutton' dentro del repeater RepeaterItem item = (RepeaterItem)(((LinkButton)(e.CommandSource)).NamingContainer); //Obtiene valores del item seleccionado (título y precio) string titulo = ((Label)item.FindControl("lblTitulo")).Text; string precio = ((Label)item.FindControl("lblPrecio")).Text; //Insertamos los datos del usuario a la tabla para la comparación de datos posteriormente DatosLibro.Titulo = titulo; DatosLibro.Precio = precio; //Datos para obtener el id String[] cart1 = new String[0]; cart1 = (String[])Session["ALL"]; //Obtenemos su Id del usuario. int ID = int.Parse(cart1[5]); //Obtenemos los datos del usuario. //Variable que tendra el id string IDIns = DAOLibros.ProcesarLibroPaypal(DatosLibro, ID); //Método para activar la sesión para enviar al proceso de pago SetOrderingValue(titulo, "BB01", precio, "1", "1", IDIns); ////Redirige al proceso de pago con los datos del libro elegido ya en la sesión. Response.Redirect("~/Forms/ProcesarPago.aspx"); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "SeguirFail();", true); } } if (e.CommandName == "details") { //Busca una referencia al 'linkbutton' dentro del repeater RepeaterItem item = (RepeaterItem)(((LinkButton)(e.CommandSource)).NamingContainer); //Obtiene valores del item seleccionado (título y precio) string titulo = ((Label)item.FindControl("lblTitulo")).Text; string precio = ((Label)item.FindControl("lblPrecio")).Text; string categoria = ((Label)item.FindControl("lblCat")).Text; string sinopsis = ((Label)item.FindControl("lblSinop")).Text; string autor = ((Label)item.FindControl("Label2")).Text; string estatus = ((Label)item.FindControl("Label3")).Text; //Image imgPortada = (Image)item.FindControl("imgPortada"); Image imgPortada = (ImageButton)item.FindControl("imgPortada"); Image fotoAutor = (Image)item.FindControl("imgAutor"); string imgRuta = imgPortada.ImageUrl; string imgAutor = fotoAutor.ImageUrl; System.Collections.Hashtable ht = new System.Collections.Hashtable(); ht.Add("Titulo", titulo); ht.Add("Precio", precio); ht.Add("Categoria", categoria); ht.Add("Sinopsis", sinopsis); ht.Add("Autor", autor); ht.Add("Estatus", estatus); ht.Add("ImagenPortada", imgRuta); ht.Add("ImagenAutor", imgAutor); Session["LibroDetalle"] = ht; Response.Redirect("/details?book=" + titulo); } if (e.CommandName == "detailsI") { //Busca una referencia al 'linkbutton' dentro del repeater RepeaterItem item = (RepeaterItem)(((ImageButton)(e.CommandSource)).NamingContainer); //Obtiene valores del item seleccionado (título y precio) string titulo = ((Label)item.FindControl("lblTitulo")).Text; string precio = ((Label)item.FindControl("lblPrecio")).Text; string categoria = ((Label)item.FindControl("lblCat")).Text; string sinopsis = ((Label)item.FindControl("lblSinop")).Text; string autor = ((Label)item.FindControl("Label2")).Text; string estatus = ((Label)item.FindControl("Label3")).Text; //Image imgPortada = (Image)item.FindControl("imgPortada"); Image imgPortada = (ImageButton)item.FindControl("imgPortada"); Image fotoAutor = (Image)item.FindControl("imgAutor"); string imgRuta = imgPortada.ImageUrl; string imgAutor = fotoAutor.ImageUrl; System.Collections.Hashtable ht = new System.Collections.Hashtable(); ht.Add("Titulo", titulo); ht.Add("Precio", precio); ht.Add("Categoria", categoria); ht.Add("Sinopsis", sinopsis); ht.Add("Autor", autor); ht.Add("Estatus", estatus); ht.Add("ImagenPortada", imgRuta); ht.Add("ImagenAutor", imgAutor); Session["LibroDetalle"] = ht; Response.Redirect("/details?book=" + titulo); } if (e.CommandName == "profile") { if (Session["Usuario"] != null) { RepeaterItem item = (RepeaterItem)(((LinkButton)(e.CommandSource)).NamingContainer); lblUser.Text = ((Label)item.FindControl("Label2")).Text; DataTable dtuser = new DataTable(); dtuser = DAOUsers.ConsultaDatosUsuario(lblUser.Text); lblUserMail.Text = dtuser.Rows[0]["Correo"].ToString(); ImagenUsuario.ImageUrl = "/images/Users/" + dtuser.Rows[0]["Imagen"].ToString(); dtuser = null; dtuser = DAOUsers.ConsultaDatosLibrosXUsuario(lblUser.Text); TotalLibros.Text = "Libros: " + dtuser.Rows[0]["Libros"].ToString(); if (isFollow(lblUser.Text)) //Si ya lo sigue, entonces no debe poder seguirlo { lbtnFollow.Visible = false; lblFollower.Visible = true; string[] userr = lblUser.Text.Split(' '); lblFollower.Text = "Ya sigues a " + userr[0].ToString() + ". Genial!"; } else { lblFollower.Visible = false; //Si no, pues puede seguirlo lbtnFollow.Visible = true; lbtnFollow.Text = "Seguir"; } ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "showModal();", true); } else { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "Session();", true); } } }