Link to home
Create AccountLog in
Avatar of Seven price
Seven priceFlag for United States of America

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Seven price

ASKER

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