ASP.NET MVC ComboBox - RadioButtons inside the ComboBox


Order
The items of the ComboBox can be customized using templates. You can embed any content inside an item template, including HTML markup and ASP.NET MVC controls (any control from the Obout MVC Suite may be added to a template).

In order to set up an item template, use the ItemTemplate property of the ComboBox. You can display any data field in the item template, by using the ComboBoxItem.DataItem object.

This example showcases the use of OboutRadioButton controls inside the ComboBox. The end user is able to select only one item from the ComboBox. To accomplish this layout, we used a single item in the ComboBox, with no value/text, which is customized using an ItemTemplate to contain all the radio buttons.
View

    <% Html.Obout(new ComboBox("ComboBox1")
    {   
        Width = 200,
        MenuWidth = 500,
        ItemTemplate = (item) =>
        {%>
            <div class="column">
                <h4>ASP.NET Controls</h4>
                <hr />
                
                <% Html.Obout(new OboutRadioButton("OboutRadioButton1")
                {
                    Text = "TreeView",
                    GroupName = "Items",
                    ClientSideEvents = new OboutRadioButtonClientSideEvents() 
                    { 
                        OnCheckedChanged = "onCheckedChanged" 
                    }
                }); %>                
                
                <br />
                
                <% Html.Obout(new OboutRadioButton("OboutRadioButton2")
                {
                    Text = "Grid",
                    GroupName = "Items",
                    ClientSideEvents = new OboutRadioButtonClientSideEvents() 
                    { 
                        OnCheckedChanged = "onCheckedChanged" 
                    }
                }); %>
                ...
    }); %> 

    <% Html.Obout(new OboutButton("OboutButton1")
    {
        Text = "Order"
    }); %>
    
    
CSS

    .ob_iCboICBC li, .ob_iCboICBC li div.b
    {
        height: 200px !important;
        color: #2b4c61 !important;
    }
        
    .ob_iCboICBC li.ih, .ob_iCboICBC li.ih div.b, .ob_iCboICBC li.ih i
    {
        background-image: none !important;
    }
        
    .column
    {
        float: left;
        width: 130px;
        margin-right: 15px;
    }
        
    .column h4
    {
        font-size: 10px;
    }
    
    
Controller

    public ViewResult IntegrationRadioButtons(string ComboBox1, 
    string ComboBox1_SelectedText, string Items)
    {
        List item = new List();
        item.Add(new ComboBoxItem() { Selected = true });

        ViewData["ComboBox1"] = item;

        if (!string.IsNullOrEmpty(ComboBox1_SelectedText))
        {
            ViewData["OrderDetails"] = "<br /><br /><b>The following control have been ordered:</b> " 
            + ComboBox1_SelectedText;
        }

        return View();
    }
    
    
obout.com 
obout.com Home 
News 
ASP.NET MVC ComboBox Home   
ASP.NET MVC ComboBox Home 
Examples - 53
Appearance - 1 
Live Styles 
Autocomplete & Filtering - 2 
Autocomplete  
Filtering  
Load on Demand - 7 
Load Items on Demand 
Load Items on Demand with Paging  
Virtual Scrolling  
Initial Text  
Initial Text on Client-Side  
Load Items on Button Click  
Load Items with MinChars  
Multi-Columns - 4 
Grid-like Multi-Columns  
Grid-like Multi-Columns & Tooltips  
Multiple Rows and Columns  
State Selector  
Items with Icons - 3 
Items with Icons  
Grid-like Multi-Columns with Icons  
Multiple Rows and Columns with Icons  
Templates - 3 
Item Templates  
Header Templates  
Populating with Data - 1 
Populate with Data  
Item Selection - 6 
Single Item Selection  
Multi Item Selection  
Get Selected Item  
Get Selected Items  
Set Selected Item  
Set Selected Items  
Mode - 2 
ComboBox  
TextBox  
Master/Detail - 3 
Master/Detail  
Unlimited Detail Levels  
Cascading ComboBoxes  
Integration - 3 
Items with ASP.NET CheckBoxes  
Items with Obout CheckBoxes  
RadioButtons inside ComboBox  
Settings - 8 
AllowCustomText  
AllowEdit  
AutoPostback  
AutoValidate  
Height  
MenuWidth  
OpenOnFocus  
Width  
Server-Side API - 2 
Server-Side Events  
Enable / Disable  
Client-Side API - 8 
Client-Side Events  
Add / Remove Items  
Add Multi-Column Items  
Enable / Disable  
Get Selected Item  
Reset Selection  
Select / Deselect All Items  
Move Items  
Documentation - 1 
ChangeLog