This is a migrated thread and some comments may be shown as answers.

Image not showing in ComboBox

2 Answers 66 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
sbowman
Top achievements
Rank 1
sbowman asked on 27 Jan 2009, 12:51 AM
I'm trying to have a combo box display a list of images with thumbnails and the image file name. The thumbnails are not showing up. I'm getting the red X in its place in Internet Explorer and nothing shows up in Mozilla Firefox. How do I fix this?

Protected

Sub BindToImageList(ByVal combo As RadComboBox)

 

 

''Populate the datatable

 

 

Dim sConnString As String = ConfigurationManager.ConnectionStrings("PU89").ConnectionString

 

 

Dim objConnection As New SqlClient.SqlConnection(sConnString)

 

 

Dim strSQL As String

 

strSQL =

"SELECT * FROM tblPhotoGallery; "

 

 

Dim objDR As SqlDataReader

 

 

Dim command As New SqlClient.SqlCommand(strSQL, objConnection)

 

 

Dim strFullPath As String

 

 

Dim strFileName As String

 

 

Me.rcboImage.Items.Add(New RadComboBoxItem("", ""))

 

 

Try

 

objConnection.Open()

objDR = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

 

While objDR.Read()

 

strFullPath = objDR(

"ImagePath")

 

strFileName = Path.GetFileName(strFullPath)

 

Me.rcboImage.Items.Add(New RadComboBoxItem(strFileName, strFileName))

 

 

Me.rcboImage.FindItemByText(strFileName).ImageUrl = objDR("ImagePath")

 

 

Me.rcboImage.FindItemByText(strFileName).DisabledImageUrl = objDR("ImagePath")

 

 

End While

 

 

 

Catch ex As Exception

 

Response.Write(ex.Message)

Response.End()

 

Finally

 

 

If objConnection.State = ConnectionState.Open Then

 

objConnection.Close()

 

End If

 

 

End Try

 

 

End Sub

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Simon
Telerik team
answered on 27 Jan 2009, 08:13 AM
Hi sbowman,

The URLs of the Images should be relative to the location of the Page (aspx file) where the RadComboBox is.

As an example, please see this live demo.

Sincerely yours,
Simon
0
sbowman
Top achievements
Rank 1
answered on 27 Jan 2009, 05:47 PM
Thanks! That fixed it.

Protected

Sub BindToImageList(ByVal combo As RadComboBox)

 

 

''Populate the datatable

 

 

Dim sConnString As String = ConfigurationManager.ConnectionStrings("PU89").ConnectionString

 

 

Dim objConnection As New SqlClient.SqlConnection(sConnString)

 

 

Dim strSQL As String

 

strSQL =

"SELECT * FROM tblPhotoGallery; "

 

 

Dim objDR As SqlDataReader

 

 

Dim command As New SqlClient.SqlCommand(strSQL, objConnection)

 

 

Dim strFullPath As String = "~/Images/PhotoGallery/"

 

 

Dim strFileName As String

 

 

Me.rcboImage.Items.Add(New RadComboBoxItem("", ""))

 

 

Try

 

objConnection.Open()

objDR = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

 

While objDR.Read()

 

strFileName = objDR(

"ImagePath")

 

 

Me.rcboImage.Items.Add(New RadComboBoxItem(strFileName, strFileName))

 

 

Me.rcboImage.FindItemByText(strFileName).ImageUrl = strFullPath & strFileName

 

 

Me.rcboImage.FindItemByText(strFileName).DisabledImageUrl = strFullPath & strFileName

 

 

End While

 

 

 

Catch ex As Exception

 

Response.Write(ex.Message)

Response.End()

 

Finally

 

 

If objConnection.State = ConnectionState.Open Then

 

objConnection.Close()

 

End If

 

 

End Try

 

 

End Sub

 

Tags
ComboBox
Asked by
sbowman
Top achievements
Rank 1
Answers by
Simon
Telerik team
sbowman
Top achievements
Rank 1
Share this question
or