ComponentOne ASP.NET MVC Controls
Custom ListBox
ASP.NET MVC Controls > Controls > Input > Controls > ListBox > Work with ListBox > Custom ListBox

You can customize the ListBox control by using ItemTemplates to specify custom content in it. You can also use ASP.NET MVC Edition controls in the template for ListBox.

The following image shows how the ListBox appears on applying ItemTemplates:

The following code examples demonstrate how to use ItemTemplates to customize the ListBox control:

In Code


Copy Code
public ActionResult ItemTemplate()
    var list = MVCFlexGrid.Models.CustomerOrder.GetOrderData(100).ToList();
    return View(list);


Copy Code
@model List<MVCFlexGrid.Models.CustomerOrder>
    .badge {
        color: white;
        background-color: darkred;
        border-radius: 10px;
        padding: 1px 10px;
    .label {
        color: black;
        background-color: orange;
        border-radius: 10px;
        padding: 1px 10px;

<script id="template1" type="text/template">
        <span class="label">{{Product}}</span>
        <span class="badge">{{Count}}</span>
    <label>Custom HTML</label>

Back to Top