kendo ui dropdownlist mvc update index

kendo ui dropdownlist mvc update index

@model MvcApplication1.Models.Contract

@{
    MvcApplication1.Models.UserSession userSession = (MvcApplication1.Models.UserSession)Session["userSession"];
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    <div class="form-group">
        @Html.LabelFor(model => model.CType, new { @class = "control-label col-sm-4" })
        <div class="col-sm-8 col-md-6">
            @(Html.Kendo().DropDownListFor(model => model.CType)
                    .Name("CTypeID")
                    )
            @Html.ValidationMessage("Please select CType")
        </div>
    </div>
}

<script type="text/javascript">
        try {
            $.getJSON("/api/Company/GetCompany/@userSession.TenantID",
                function (data) {
                    var types = [{ 'ID': '1', 'CType': 'A' },
                        { 'ID': '2', 'CType': 'B' },
                        { 'ID': '3', 'CType': 'C' },
                        { 'ID': '4', 'CType': 'D' },
                        { 'ID': '5', 'CType': 'E' }];

                    var index;
                    $.each(types, function (key, val) {
                        if (val.ID == "@Model.CTypeID") {
                            index = key;
                        }
                    });

                    $('#CTypeID').kendoDropDownList({
                        dataTextField: 'CType',
                        dataValueField: 'ID',
                        dataSource: cancellationTypes,
                        index: index
                    });
                });
                }
        catch (ex) {
            //Log the exception and alert to the end user
            kendoDialogForEndUserAlert("Error", ex, "Error", ["OK"], null);
        }
    });
</script>



ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
http://www.code-sample.com
http://www.code-sample.xyz

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.