ASP.NET - CARGAR FOTOS EN UN GRIDVIEW

 
Vista:
sin imagen de perfil

CARGAR FOTOS EN UN GRIDVIEW

Publicado por ANTONIO (106 intervenciones) el 21/04/2008 14:39:11
Hola amigos buenas tardes estoy intentando hacer este siemple ejemplo:
Inserto un gridview en mi formulario web, aparte tengo una carpeta llamada fotos que contiene cinco fotos .jpg.
Bueno lo unico que quiero es que cuando pulse un boton el gridview se cargue con esas cinco fotos nada mas y no tengo ni idea de como se hace.
Yo pensaba que agregando un imagefield al gridview y en la propiedad DataImageUrlFormat PONIENDO ALGO COMO ~/FOTOS/{0} iba a funcionar pero no.
Bueno espero vuestra ayuda amigos.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:CARGAR FOTOS EN UN GRIDVIEW

Publicado por Javier Santamaria (312 intervenciones) el 22/04/2008 13:12:07
Hola,

Sin probarlo se me ocurre que agregues esos imagefields al gridview, pero te tocara llenar el valor de la url en tiempo de ejecucion en el page load o algo asi

Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

RE:CARGAR FOTOS EN UN GRIDVIEW

Publicado por ANTONIO (106 intervenciones) el 22/04/2008 19:21:59
Bueno ya lo he conseguido aqui pongo en codigo html y vb.net para el que lo necesite:
codigo html:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>VISOR DE FOTOS</title>
</head>
<body>
<form id="form1" runat="server">
<div>
            
<asp:Button ID="Button3" runat="server" Style="left: 146px; position: absolute; top: 14px"
Text="PROCESAR" Width="100px" />
<asp:GridView ID="GridView1" Runat="server"
DataSource='<%# GetData() %>' AutoGenerateColumns="False"
BorderWidth="1px" BackColor="White" CellPadding="3" BorderStyle="None"
BorderColor="#CCCCCC" Font-Names="Arial" style="left: 88px; position: absolute; top: 51px">
<FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>
<PagerStyle ForeColor="#000066" HorizontalAlign="Left"
BackColor="White"></PagerStyle>
<HeaderStyle ForeColor="White" Font-Bold="True"
BackColor="#006699"></HeaderStyle>
<Columns>
<asp:BoundField HeaderText="ARCHIVO" DataField="ARCHIVO"></asp:BoundField>
<asp:ImageField DataImageUrlField="IMAGENURL"></asp:ImageField>
</Columns>
<SelectedRowStyle ForeColor="White" Font-Bold="True"
BackColor="#669999"></SelectedRowStyle>
<RowStyle ForeColor="#000066"></RowStyle>
</asp:GridView>
</div>
</form>
</body>
</html>

CODIGO VB.NET
Imports System.IO
Imports System.DATA
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Page.DataBind()
End Sub
Function GetData() As DataTable
Dim dt As New DataTable()
Dim VALOR As Integer
dt.Columns.Add(New DataColumn("IMAGENURL", GetType(String)))
dt.Columns.Add(New DataColumn("ARCHIVO", GetType(String)))
Dim f As String()
f = System.IO.Directory.GetFiles(Server.MapPath("FOTOS"), "*.jpg")
For Each i As String In f
Dim x As New System.IO.FileInfo(i)
i = x.Name
Dim dr As DataRow = dt.NewRow()
dr("IMAGENURL") = ResolveUrl("~/FOTOS/" & i)
dr("ARCHIVO") = i
dt.Rows.Add(dr)
Next
Return dt
End Function
End Class

Saludos y gracias a todos por haberme ayudado.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:CARGAR FOTOS EN UN GRIDVIEW

Publicado por Jose Luis (1 intervención) el 17/10/2014 07:57:54
Yo tengo ese problema si tuvieran la solución en asp.net
Gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar