I have a RadComboBox with an empty message on my page inside a radgrid. The combobox is populated in the ItemDataBound event for the containing grid. The empty message shows in each radcombobox on the page.
My problem is that the position may have been selected previously & although I could get the value to display, since putting in the empty message, it does not show this value. The empty message is shown, even though this particular combobox is not empty.
The previously selected item does appear in the drop down but the radcombobox seems to be thinking it is still empty. Have I missed something?
asp:
<telerik:RadComboBox ID="cboPosi" runat="server" DataSourceID="LabourDataSource" AllowCustomText="True"
DataTextField="Pos" DataValueField="PosDesc" EnableAutomaticLoadOnDemand="true" ShowMoreResultsBox="true"
EnableVirtualScrolling="true" ItemsPerRequest="10" EmptyMessage="Type here">
</telerik:RadComboBox>
vb.net:
Dim combo As RadComboBox = DirectCast(item.FindControl("cboPosi"), RadComboBox)
Dim selectedItem As New RadComboBoxItem()
selectedItem.Text = selectedTitle
selectedItem.Value = selectedVal
combo.Items.Add(selectedItem)
selectedItem.DataBind()
The problem turned out to be that I was not actually selecting the new item I had made. Without an empty message, this item was being displayed as selected.
Setting the inserted item as the selected item causes it to be displayed correctly instead of the empty message:
Dim combo As RadComboBox = DirectCast(item.FindControl("cboPosi"), RadComboBox)
Dim selectedItem As New RadComboBoxItem()
selectedItem.Text = selectedTitle
selectedItem.Value = selectedVal
combo.Items.Add(selectedItem)
selectedItem.DataBind()
combo.SelectedIndex = 0