We help IT Professionals succeed at work.

programatic table with image

below i am trying to compare the image names with the name in the database. but for some reason I only can read one image name but nothing after. I tried to split it. Not sure the correct syntax to get this working.

Do While sqlDR.Read
                Dim strFileSize As String = ""
                Dim di As New IO.DirectoryInfo(Server.MapPath("images"))
                Dim aryFi As IO.FileInfo() = di.GetFiles("*.*")
                Dim fi As IO.FileInfo

                For Each fi In aryFi
                    If fi.Extension = ".jpg" then


                        strFileSize = (Math.Round(fi.Length / 1024)).ToString()

                        Dim s As String = fi.Name

                       
                         Dim words As String() = s.Split(New Char() {" "c})
                        For Each word In words

                            Dim mypath = "images" + sqlDR("photonumber") + "/"
                            Dim mysunday As String = sqlDR("photonumber")
                            r = New TableRow ' << place here start new row
                            c = New TableCell ' << place here start new table cell
                            cnt = cnt + 1

                            img = New ImageButton
                            img.Width = "100"
                            img.Attributes.Add("onclick", "")
                            If sqlDR("UPC").ToString() + ".jpg" = word Then
                                img.ImageUrl = mypath + sqlDR("photonumber").ToString() + ".jpg"
                            Else
                                img.ImageUrl = "images/blankimage.png"
                            End If
                            img.ID = "myNewimage" + cnt.ToString()
                            c.Controls.Add(img)
                            r.Cells.Add(c)

                        Next
                    End If
                Next

             

                                newItem.Rows.Add(r)
            Loop
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008
Commented:
What do you mean by "I only can read one image name but nothing after"?  Are you finding multiple files?  Are you getting words.Length > 1?
Seven priceFull Stack

Author

Commented:
I figured it out. but to much code to explain but thanks learned one.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.