RadComboBox Value Property

9 posts, 0 answers
  1. JJ
    JJ avatar
    21 posts
    Member since:
    Jan 2008

    Posted 25 Jan 2008 Link to this post

    How do I set the 'Value' property on my item?  I see that the 'Text' property is available, but no 'Value'.

    Thanks,

    Jeff

  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 28 Jan 2008 Link to this post

    Hi Jeff Johnson,

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hoon
    Hoon avatar
    7 posts
    Member since:
    Oct 2010

    Posted 28 Dec 2010 Link to this post

    http://www.telerik.com/help/aspnet/combobox/comboitemsrequested.html

    I'm sorry but your explanation is inconsistent as above. How can I acess the selectedvalue after bindingdata with itemsrequested.
  5. msigman
    msigman avatar
    141 posts
    Member since:
    Apr 2008

    Posted 28 Dec 2010 Link to this post

    Are you trying to access the SelectedValue, or set it?  In your first post you said set it, but in the second you ask how to access it...

    You access it by using ComboBox.SelectedValue;

    And you set it by using DataValueField and then DataBind()ing.
  6. Tim
    Tim avatar
    7 posts
    Member since:
    Sep 2007

    Posted 02 Mar 2012 Link to this post

    Was there a solution here to the scenario that Hoon brought up?  I have the exact same issue with the ‘Value’ property missing and not allowing me to assign a value when I handle the OnItemsRequested event.  This worked in one of the 2008 versions of ASP.NET.
  7. msigman
    msigman avatar
    141 posts
    Member since:
    Apr 2008

    Posted 04 Mar 2012 Link to this post

    Hi Tim,

    What about using ComboBox.SelectedItem.Value?
  8. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 08 Mar 2012 Link to this post

    Hi Tim,

    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
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  9. Tim
    Tim avatar
    7 posts
    Member since:
    Sep 2007

    Posted 10 Apr 2012 Link to this post

    One of the issues would be getting the value (not just the text) and this workaround would indeed be a solution.  However, I need to be able to store both a string in the control and an index (integer) in the control.  Am I missing something?  This RadComboBox is being used within a RadGrid when using the edit template and the databinding is being loaded in the code-behind. 

    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'


  10. Tim
    Tim avatar
    7 posts
    Member since:
    Sep 2007

    Posted 10 Apr 2012 Link to this post

    After reviewing some other examples, in my own code nonetheless, I am indeed missing some key points.   Here was how I implemented the solution:

     

     

    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

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017