I have a Data Repeater to which I need to add x number of images depending on their existence in the database.
I need the images added within hyperlinks for Javascript functionality. In order to dynamically add the hyperlinks and images I have placed them within a panel in the data repeater and am adding them in the ItemDataBound event.
The problem is that only the first image is being written to the datarepeater.
Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) Handles myDataRepeater.ItemDataBound
Dim myPanel As Panel = e.Item.FindControl("pnlImages")
Dim myLink As New System.Web.UI.WebControls.HyperLink
Dim myImage As New System.Web.UI.WebControls.Image
Dim myProperty As String = Request.QueryString("ID")
Dim dirInfo As New DirectoryInfo(Server.MapPath("~/ftp/images/"))
Dim fs_infos() As FileInfo = dirInfo.GetFiles("*" + myProperty.Substring(1) + "*")
For Each fs_info As FileInfo In fs_infos
If fs_info.Name.Substring(8, 1) <> "P" Then
myLink.ID = fs_info.Name
myLink.NavigateUrl = "~/ftp/images/" + fs_info.Name
myLink.Attributes.Add("onClick", "return hs.expand(this)")
myLink.Width = 90
myImage.ID = "img" + fs_info.Name
myImage.ImageUrl = "~/ftp/images/" + fs_info.Name
myImage.Width = 80
myImage.Height = 60
myLink.Controls.Add(myImage)
myPanel.Controls.Add(myLink)
End If
Next fs_info
fs_infos = Nothing
End Sub
Any ideas as to what I am doing wrong - or a better way of doing things?