Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i gave the properties using list and unable to display the list

What I have tried:

model
public List<SelectListItem> SelectQualifierType
        {

            get
            {
                List<SelectListItem> list = new List<SelectListItem>();
                list.Add(new SelectListItem { Text = "Select", Value = "0" });
                list.Add(new SelectListItem { Text = "LR100", Value = "1" });
                list.Add(new SelectListItem { Text = "LR50", Value = "2" });

                var sortedList = list.OrderBy(l => l.Value);
                SelectQualifierTypeID = "0";
                return sortedList.Select(l => new SelectListItem { Selected = (l.Value == SelectQualifierTypeID), Text = l.Text, Value = l.Value }).ToList();

            }

        }


client


<div class="col-md-1">
                            @Html.LabelFor(x => x.SelectLicenseTypeViewModel.Qualifier)
                        </div>
                        @(Html.Kendo().DropDownListFor(x => x.SelectLicenseTypeViewModel.Qualifier).Name("Qualifier")

                    .HtmlAttributes(new { style = "width:180px", @class = "form-control ", @id = "ddlQualifierType", @readonly = "true" }))
                        @Html.ValidationMessageFor(x => x.SelectLicenseTypeViewModel.Qualifier)


                        <br />
Posted
Updated 10-Apr-18 3:46am

I don't see any where in the view code you using the property of Model SelectQualifierType which is holding the items that needed to be used in DropDown for it to be populated.

You are not calling the BindTo method which is needed for specifying the List<SelectListItem> which will be used to fill the dropdown list with items. Please have a look at the official documentation with demo and sample code:

https://demos.telerik.com/aspnet-mvc/dropdownlist

Hope it helps!
 
Share this answer
 
v2
@Html.LabelFor(x => x.SelectLicenseTypeViewModel.Qualifier)
                        </div>
                        @(Html.Kendo().DropDownListFor(x => x.SelectLicenseTypeViewModel.Qualifier).BindTo(Model.SelectLicenseTypeViewModel.SelectQualifierType).Name("Qualifier")

                    .HtmlAttributes(new { style = "width:180px", @class = "form-control ", @id = "ddlQualifierType", @readonly = "true" }))
                        @Html.ValidationMessageFor(x => x.SelectLicenseTypeViewModel.Qualifier)


                        <br />



i tired Not working
 
Share this answer
 
Comments
Richard Deeming 6-Jun-18 11:21am    
If you want to reply to a solution, click the "Have a Question or Comment?" button under that solution.

DO NOT post your reply as a new "solution".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900