15/04/2010, 12:02
|
| | Fecha de Ingreso: febrero-2010
Mensajes: 24
Antigüedad: 14 años, 10 meses Puntos: 0 | |
Respuesta: Repeater carga imagenes de un directorio Bueno nadie me pudo ayudar(porfavor moderadores todos sabes que ustedes dominan mucha asp.net, traten de darnos una manito), pero aqui esta la solucion la encontre.
behingCode:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim myDV As DataView
myDV = CreateDataSource
' Repeater that outputs plain comma seperated data
Rp_Producto.DataSource = myDV
Rp_Producto.DataBind()
End Sub
Function CreateDataSource() As DataView
Dim myDataTable As New DataTable
Dim myDataRow As DataRow
Dim myDataView As DataView
myDataTable.Columns.Add(New DataColumn("DirImagen", System.Type.GetType("System.String")))
myDataTable.Columns.Add(New DataColumn("NombreImg", System.Type.GetType("System.String")))
Dim NomCat As String
Dim NomFile As String
Dim j As Integer = 0
NomCat = Request("categoria")
NomCat = Replace(NomCat, "'", "")
If NomCat <> Nothing Then
Dim imagenes(Directory.GetFiles(Server.MapPath("../a-1premium/images/" & NomCat & "/thumbnail/")).Length, 1) As String
Dim sFile As String
For Each sFile In Directory.GetFiles(Server.MapPath("../a-1premium/images/" & NomCat & "/thumbnail/"))
NomFile = Path.GetFileNameWithoutExtension(sFile).ToString ' solo es el nombre
If NomFile <> "Thumbs" Then
sFile = Replace(sFile, "\", "/")
Dim i As Integer = 0
i = InStr(sFile, "images")
Dim QuitarSec As String
QuitarSec = Left(sFile, i - 1)
sFile = Replace(sFile, QuitarSec, "")
myDataRow = myDataTable.NewRow
myDataRow(0) = sFile
myDataRow(1) = NomFile
myDataTable.Rows.Add(myDataRow)
End If
Next
End If
myDataView = New DataView(myDataTable)
CreateDataSource = myDataView
End Function
Client code:
<asp:Repeater ID="Rp_Producto" runat="server">
<ItemTemplate>
<div class="Listado_Copas">
<p><img src="<%# DataBinder.Eval(Container.DataItem, "DirImagen") %>" /></p>
<p>
<%#DataBinder.Eval(Container.DataItem, "NombreImg")%></p>
</div>
</ItemTemplate>
</asp:Repeater> |