ASPX dropdownlist does not load image

Asked

Viewed 17 times

0

I’m doing a dropdownlist to present only image, but this does not work, as this article macoratti.net/14/11/aspn_ddli1.htm .

I even downloaded it and ran it on my machine and it didn’t work, could help?

Public Function DtLstIconeOdonto() As DataTable
        Dim dtb As DataTable = New DataTable()
        dtb.Columns.Add("icone", GetType(String))
        dtb.Columns.Add("Id", GetType(Long))
        dtb.Columns.Add("LabelValue")
        Dim _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 1
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 2
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 3
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 4
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 5
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 6
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 7
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 8
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 9
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 10
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 11
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 12
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 13
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 14
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 15
        dtb.Rows.Add(_olinha)
        _olinha = dtb.NewRow()
        _olinha("icone") = ""
        _olinha("Id") = 16
        dtb.Rows.Add(_olinha)
        Return dtb
    End Function


Protected Sub lstIconeAtalhoOdontograma_Bindata(ByVal sender As Object, ByVal e As EventArgs)
    lstIconeAtalhoOdontograma.DataSource = DtLstIconeOdonto()
    lstIconeAtalhoOdontograma.DataTextField = "icone"
    lstIconeAtalhoOdontograma.DataValueField = "Id"
    lstIconeAtalhoOdontograma.DataBind()
    Dim imageURL As String = ""

    For i As Integer = 0 To lstIconeAtalhoOdontograma.Items.Count - 1

        Select Case lstIconeAtalhoOdontograma.Items(i).Value
            Case "1"
                imageURL = "../icons/RealOdonto/img_1.png"
            Case "2"
                imageURL = "../icons/RealOdonto/img_2.png"
            Case "3"
                imageURL = "../icons/RealOdonto/img_3.png"
            Case "4"
                imageURL = "../icons/RealOdonto/img_4.png"
            Case "5"
                imageURL = "../icons/RealOdonto/img_5.png"
            Case "6"
                imageURL = "../icons/RealOdonto/img_6.png"
            Case "7"
                imageURL = "../icons/RealOdonto/img_7.png"
            Case "8"
                imageURL = "../icons/RealOdonto/img_8.png"
            Case "9"
                imageURL = "../icons/RealOdonto/img_9.png"
            Case "10"
                imageURL = "../icons/RealOdonto/img_10.png"
            Case "11"
                imageURL = "../icons/RealOdonto/img_11.png"
            Case "12"
                imageURL = "../icons/RealOdonto/img_12.png"
            Case "13"
                imageURL = "../icons/RealOdonto/img_13.png"
            Case "14"
                imageURL = "../icons/RealOdonto/img_14.png"
            Case "15"
                imageURL = "../icons/RealOdonto/img_15.png"
            Case "16"
                imageURL = "../icons/RealOdonto/img_16.png"
        End Select
        Dim item As ListItem = lstIconeAtalhoOdontograma.Items(i)
        item.Attributes("style") = "background-image: url(" & imageURL & ");background-repeat:no-repeat;"
    Next
End Sub

...

In F12 it presents the right image, but in the dropdownlist does not load, would have any idea what could be?

  • Without seeing the Markup and how it is rendering in html there is no way to help... No quotation marks are missing in url('" & imageURL & "')

  • Sorry for the delay, but unfortunately no, I could not fulfill the question, I had to create a dialog to resolve the customer issue

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.