SelectListItem Text not being displayed

I am trying to complete a form for users to sign up to an asp.net MVC website, I am struggling to get the dropdown lists to display text properly. The Model has the following:

public SelectList CountiesList;

In the constructor, entities is my database context:

CountiesList = new SelectList(
                from c in entities.Counties
                select new SelectListItem
                {
                    Value = c.CountyID.ToString(),
                    Text = c.County //the county name, nvarchar/string
                });

And in my cshtml:

<div class="align-center">
    <label>County</label>
    @Html.DropDownListFor(x => x.County, Model.DropDowns.CountiesList)
</div>

This is generating the dropdown with the right number of items from the lookup table but the displayed Text is ‘System.Web.Mvc.SelectListItem’ rather than the name of the County.

Any help is much appreciated!


Download selectlistitem.text.not.being.displayed.zip
Direct Link


Download


Download selectlistitem.text.not.being.displayed.zip
Mediafire


Download


Download selectlistitem.text.not.being.displayed.zip
Billionuploads


Download


Download selectlistitem.text.not.being.displayed.zip
Uploadable


Download


Download selectlistitem.text.not.being.displayed.zip
Filevice


Download

Both comments and pings are currently closed.

Comments are closed.