Multi Column Combo Box without Data binding

3 posts, 0 answers
  1. Mo
    Mo avatar
    5 posts
    Member since:
    Aug 2012

    Posted 03 Aug 2012 Link to this post

    So I have a items that I need fill into the combo box without having to bind the combo to a table in the database. How do I do that?

  2. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 03 Aug 2012 Link to this post

    Hello,

    <telerik:RadComboBox ID="RadComboBox1" runat="server" MarkFirstMatch="true" EmptyMessage="--Select--">
               <HeaderTemplate>
                   <table ellspacing="0" cellpadding="0">
                       <tr>
                           <td style="width: 150px;">
                               First Name
                           </td>
                           <td style="width: 150px;">
                               Last Name
                           </td>
                       </tr>
                   </table>
               </HeaderTemplate>
               <ItemTemplate>
                   <table cellspacing="0" cellpadding="0">
                       <tr>
                           <td style="width: 150px;">
                               <%# DataBinder.Eval(Container, "Attributes['FirstName']")%>
                           </td>
                           <td style="width: 150px;">
                               <%# DataBinder.Eval(Container, "Attributes['LastName']")%>
                           </td>
                       </tr>
                   </table>
               </ItemTemplate>
           </telerik:RadComboBox>


    protected void bindCombo()
        {
           
            for (int i = 0; i < 10; i++)
            {
                RadComboBoxItem item = new RadComboBoxItem();
     
                item.Text = i + "Text";
                item.Value = i + "Value";
                item.Attributes.Add("FirstName", i + "FirstName");
                item.Attributes.Add("LastName", i + "LastName");
     
                RadComboBox1.Items.Add(item);
     
                item.DataBind();
            }
        }



    Thanks,
    Jayesh Goyani
  3. Nencho
    Admin
    Nencho avatar
    1795 posts

    Posted 06 Aug 2012 Link to this post

    Hi Mohamed,

    In order to achieve the desired functionality, you could create your own RadComboBoxItems and after setting the desired attributes and values, you could add them to the RadComboBoxItemCollection. Here you could find our help article about using the RadComboBoxItems at server side.

    Kind regards,
    Nencho
    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