8 Answers, 1 is accepted
The 'Text' property of the RadComboBox refers to the text which is displayed in the text area of the control. The control does not have a corresponding 'Value' property. Still, each of its Items has a 'Value' property and it can be set either for the currently selected item (RadComboBox.SelectedItem.Value) or for a specific one through the RadComboBox 'Items' collection (RadComboBox.Items[i].Value).
All the best,
Simeon
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I'm sorry but your explanation is inconsistent as above. How can I acess the selectedvalue after bindingdata with itemsrequested.
You access it by using ComboBox.SelectedValue;
And you set it by using DataValueField and then DataBind()ing.
What about using ComboBox.SelectedItem.Value?
The help article, which Hoon referred to, is for RadComboBox for ASP.NET and we are discussing here the AJAX version of the same control. The Value property has been deprecated when the controls were migrated to the the ASP.NET AJAX Framework.
One way to work around this limitation is to have a hidden field next to the combobox and on each SelectedIndexChanged event of the latter to set the value of the selected item as value of the hidden field. This way you can obtain the selected item's value on the server after postback.
Kind regards,
Hector
the Telerik team
So at this point, this control appears to be a singular data element combo box and I'm not sure how valuable it really is to other developers. If you can't store both an index and a useful string to the UI, how can this be used in a database driven environment?
The only solution I currently see is to append my index onto the string with a separator character. But with this solution, I'll have to intercept the Insert/Update SQL command and split this out - all of which just seems like too much work.
<telerik:GridTemplateColumn UniqueName="AttendeeName" HeaderText="Attendee Name" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" DataField="AttendeeName" Visible="true">
<ItemTemplate>
<asp:Label runat="server" ID="lblAttendeeID" Text='<%# Bind("AttendeeID") %>' visible="false"></asp:Label>
<asp:Label runat="server" ID="lblAttendeeName" Text='<%# Bind("AttendeeName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox ID="cmdHost1" runat="server" Width="150px" Height="120px" Value='<%# Bind("AttendeeID") %>' Text='<%# Bind("AttendeeName") %>'
Skin="Office2010Black" AutoPostBack="True" AllowCustomText="True" ShowToggleImage="False"
EnableLoadOnDemand="True" MarkFirstMatch="False" OnItemsRequested="cmdHost1_ItemsRequested" >
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
Protected Sub cmdHost1_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs)
Dim [text] As String = e.Text
Dim conn1 As SqlConnection = Nothing
Dim oRD As SqlDataReader = Nothing
Dim cmd As SqlCommand = Nothing
Dim combo As RadComboBox = Nothing
Try
combo =
CType(o, RadComboBox)
combo.Items.Clear()
conn1 =
New SqlConnection(ConfigurationManager.ConnectionStrings("DS1").ConnectionString)
conn1.Open()
cmd =
New SqlCommand()
cmd.Connection = conn1
cmd.CommandText =
"SELECT EmployeeID, DisplayName FROM MeetingList WHERE DisplayName LIKE '" + [text].Replace("'", "''") + "%' ORDER BY DisplayName"
cmd.CommandType =
CommandType.Text
oRD = cmd.ExecuteReader()
Do While oRD.Read()
If oRD.HasRows Then
Try
Dim item As New RadComboBoxItem(oRD.Item("DisplayName").ToString().ToLower())
item.Value = oRD.Item(
"EmployeeID").ToString()
item.Text = oRD.Item(
"DisplayName").ToString()
combo.Items.Add(item)
Catch ex As Exception
End Try
End If
Loop
oRD.Close()
Catch ex As Exception
If Not oRD Is Nothing AndAlso Not oRD.IsClosed Then oRD.Close()
Finally
If conn1 IsNot Nothing Then conn1.Close()
End Try
End Sub
Parser Error Message: Two-way binding is only supported for properties. 'Value' is not a valid property on 'RadComboBox'
Protected Sub cmdHost1_OnSelectedIndexChange(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)
Dim valueLabel As Label = DirectCast(RadGrid1.MasterTableView.GetInsertItem("AttendeeName").FindControl("lblValue"), Label)
valueLabel.Text = e.Value
End Sub