Adding a 3rd item to my combo box

4 posts, 0 answers
  1. stevied
    stevied avatar
    37 posts
    Member since:
    Apr 2007

    Posted 28 Nov 2011 Link to this post

    I have a rad combo box which is being databound as follows...

    'Now populate the Managers Drop down
               rsMain = GeneralDataMethod.GetAllApprovedManagers
               While rsMain.Read
                   cboManager.Items.Add(New RadComboBoxItem(rsMain("Manager"), rsMain("ManagerID")))
     
               End While
               cboManager.Items.Insert(0, New RadComboBoxItem("- Please select -", ""))

    I would like to add a 3rd item from the database into the combo box (email address, the sp gives me this) but not display in the drop down but have it available to me when the user selects a manager from the drop down.

    Is this possible using code behind?

    TIA.

    S


  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 30 Nov 2011 Link to this post

    Hi Stevied,

    As I understand - you are populating the RadComboBox control with data from a database and you set the Text property of the RadComboBox items to "Manager" and the Value property to "ManagerID".
    In case you want to add e-mail information for each item(Manager) - you can simply set this data as a Custom Attribute.
    Please take a look at the "ComboBox / Custom Attributes" online demo and “Custom Attributes” help article.

    Best wishes,
    Kalina
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. stevied
    stevied avatar
    37 posts
    Member since:
    Apr 2007

    Posted 30 Nov 2011 Link to this post

    Thanks for your feedback Kalina, i have seen both these posts but I am using code behind to database my Rad Combo Box as the following codes shows..

    ASPX

    <Telerik:RadComboBox ID="cboManager" runat="server" AutoPostBack="true" />

    aspx.vb

    'Now populate the Managers Drop down
               rsMain = GeneralDataMethod.GetAllApprovedManagers
               While rsMain.Read
                   cboManager.Items.Add(New RadComboBoxItem(rsMain("Manager"), rsMain("ManagerID")))
     
               End While
               cboManager.Items.Insert(0, New RadComboBoxItem("- Please select -", ""))

    using this method i cannot see how or where i can add in the attibutes?

    Many thanks,

    S
  5. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 05 Dec 2011 Link to this post

    Hello Stevied,

    You could add attributes in the following manner:
    'Now populate the Managers Drop down
           rsMain = GeneralDataMethod.GetAllApprovedManagers
           While rsMain.Read
     
               Dim item As New RadComboBoxItem(rsMain("Manager"), rsMain("ManagerID"))
               item.Attributes("Attribute") = rsMain("Email")
               cboManager.Items.Add(item)
     
           End While
           cboManager.Items.Insert(0, New RadComboBoxItem("- Please select -", ""))

    Regards,
    Dimitar Terziev
    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
Back to Top