Hello. I'm working with a raddropdownlist control contained within radfilter and I have this drop down list display images for different each list item. The ImageDropDown image shows you what the display looks like when the drop down list is open. If I select a drop down list item, the item get selected but nothing displays (shown in the MissingSelection Image). However, once I apply the radfilter selection, the image will appear selected on postback (ImageSelected Image). Here's the code-behind code that is used to create the raddropdownlist for the radfilter:
Protected Sub RadFilter1_ExpressionItemCreated(sender As Object, e As RadFilterExpressionItemCreatedEventArgs) Handles RadFilter1.ExpressionItemCreated
Dim oConn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("iTask").ConnectionString)
Dim oCmd As New SqlCommand
Dim oData As SqlDataReader
Try
Dim singleItem As RadFilterSingleExpressionItem = TryCast(e.Item, RadFilterSingleExpressionItem)
If singleItem IsNot Nothing AndAlso singleItem.FieldName = "Flag" AndAlso singleItem.IsSingleValue Then
Dim dropDownList As RadDropDownList = TryCast(singleItem.InputControl, RadDropDownList)
oConn.Open()
With dropDownList
.Width = 50
Dim oBlankItem As New DropDownListItem("")
.Items.Add(oBlankItem)
With oCmd
.Parameters.Clear()
.Connection = oConn
.CommandType = CommandType.StoredProcedure
.CommandText = "iTask_Select_Flags"
End With
oData = oCmd.ExecuteReader
Do While oData.Read
Dim oItem As New DropDownListItem("")
oItem.Text = "<img src='" & CoreComponents.sImageRoot & oData("ImageFileName").ToString & "' style='cursor:pointer;' border='0'/>"
oItem.ToolTip = oData("Name").ToString
oItem.Value = oData("ImageFileName").ToString
'oItem.ImageUrl = CoreComponents.sImageRoot & oData("ImageFileName").ToString
.Items.Add(oItem)
Loop
.OnClientItemSelected = "OnClientItemSelected"
'.OnClientSelectedIndexChanged = "OnClientSelectedIndexChanged"
.DataBind()
oData.Close()
End With
End If
Catch ex As Exception
Finally
oConn.Dispose()
oConn = Nothing
oCmd = Nothing
oData = Nothing
End Try
End Sub
I attempted to use the OnClientItemSelected & OnClientSelectedIndexChanged JS code to set the image in the text element of the RadDownDownList control, but to no avail. Here's that code as well. Any help on this issue would be greatly appreciated.
function OnClientItemSelected(sender, eventArgs) {
alert('function called!');
var item = eventArgs.get_item();
//alert("You selected " + item.get_text() + " with value " + item.get_value());
sender.get_textElement().innerHTML = "<img src='<%=CoreComponents.sImageRoot%>" + item.get_value() + "' border='0'/>";
}
function OnClientSelectedIndexChanged(sender, eventArgs) {
alert("You selected item with index : " + eventArgs.get_index());
sender.get_textElement().innerHTML = sender.get_items().getItem(eventArgs.get_index()).get_text();
}