Available in the Full Version

Combo Box - ASP.NET MVC Helper

Current Employee:

Steven Buchanan

Choose New Employee

This sample is designed for a larger screen size.

On mobile, try rotating your screen, view full size, or email to another device.

This sample shows the combo used in a basic ASP.NET MVC scenario. The ASP.NET MVC helper is used to instantiate the combo in the view. In addition, the ComboDataSourceAction attribute is used to process the remote request for the collection of employees as well as process the remote filtering parameters. Finally, you can see how the combo is used in a form to update a field in the model.

Code View

Copy to Clipboard
@using Infragistics.Web.Mvc
@using IgniteUI.SamplesBrowser.Models
@model IgniteUI.SamplesBrowser.Models.Northwind.Order

<!DOCTYPE html>

<html>
<head>
    <title></title>

    <!-- Ignite UI for jQuery Required Combined CSS Files -->
    <link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
    <link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/structure/infragistics.css" rel="stylesheet" />

    <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>

    <!-- Ignite UI for jQuery Required Combined JavaScript Files -->
    <script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.core.js"></script>
    <script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.lob.js"></script>

</head>
<body>
    <style>

        .sample-ui div {
            margin-bottom: 1em;
        }

        .sample-ui h4 {
            margin-bottom: .5em;
        }

        .sample-ui #submitBtn {
            width: 100px;
        }

    </style>

    @using (Html.BeginForm())
    {
        <div class="sample-ui">
            @Html.HiddenFor(item => item.OrderID)

            <div>
                <h4>Current Employee:</h4>
                @Html.DisplayFor(item => item.EmployeeName)
            </div>

            <div>
                <h4>Choose New Employee</h4>

                @(Html.Infragistics().ComboFor(item => item.EmployeeID)
                    .Width("270px")
                    .DataSource(Url.Action("employee-combo-data"))
                    .ValueKey("ID")
                    .TextKey("Name")
                    .DataBind()
                    .Render()
                )
            </div>

            <input id="submitBtn" type="submit" value="Update" />
        </div>
    }
</body>
</html>