datalist udskrive flere værdier
HejEr der nogen der ved hvordan jeg i følgende kode kan få navnet på filen til at stå under det resizede billede..??
<%@ Import Namespace="System.IO" %>
<script language="vb" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Const IMAGE_DIRECTORY As String = "img/mobiler/"
Const maxWidth As Integer = 70
Const maxHeight As Integer = 70
Dim pics as ArrayList = new ArrayList()
Dim s as String, html as String
Dim imgHeight, imgWidth as Integer
For Each s In Directory.GetFiles(Server.MapPath(IMAGE_DIRECTORY), "*.jpg")
'Get information about the image
Dim currentImage As System.Drawing.Image = System.Drawing.Image.FromFile(s)
imgHeight = currentImage.Height
imgWidth = currentImage.Width
If imgWidth > maxWidth Or imgHeight > maxHeight Then
'Determine what dimension is off by more
Dim deltaWidth As Integer = imgWidth - maxWidth
Dim deltaHeight As Integer = imgHeight - maxHeight
Dim scaleFactor As Double
If deltaHeight > deltaWidth Then
'Scale by the height
scaleFactor = maxHeight / imgHeight
Else
'Scale by the Width
scaleFactor = maxWidth / imgWidth
End If
imgWidth *= scaleFactor
imgHeight *= scaleFactor
End If
If imgHeight <> currentImage.Height Or imgWidth <> currentImage.Width Then
html = "<a href=""" & IMAGE_DIRECTORY & Path.GetFileName(s) & """>" & _
"<img border=""0"" src=""ShowThumbnail.aspx?img=" & Path.GetFileName(s) & "&w=" & _
imgWidth & "&h=" & imgHeight & """ " & _
"height=""" & imgHeight & """ width=""" & imgWidth & """>" & _
"</a>"
Else
html = "<a href=""" & IMAGE_DIRECTORY & Path.GetFileName(s) & """>" & _
"<img border=""0"" src=""ShowThumbnail.aspx?img=" & Path.GetFileName(s) & """ " & _
"height=""" & imgHeight & """ width=""" & imgWidth & """>" & _
"</a>"
End If
pics.Add(html)
Next
dlPictures.DataSource = pics
dlPictures.DataBind()
End Sub
</script>
<asp:DataList runat="server" id="dlPictures"
RepeatColumns="6" CellSpacing="24" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<%# Container.DataItem %>
</ItemTemplate>
</asp:DataList>
