I’m rendering a dropdownlist that has an integer value and the SelectListItem value attribute only accepts a string thus the need for conversion. .ToString() function cannot be used.
@Html.DropdownList("ddl", Model.recordList.Select(
q => new SelectListItem
{
Text = q.recordName,
Value = SqlFunctions.StringConvert(q.recordId)
}
, "choose one")
// recordId is an Integer
I get assembly reference error on runtime:
The type or namespace name 'Objects' does not exist in the namespace
'System.Data' (are you missing an assembly reference?)
There is a project reference to System.Data.Entity already and @using System.Data.Objects.SqlClient in my View. I’m expecting this too as it doesn’t appear in Intellisense. I can use from Controllers but not in Views.
Am I breaking any MVC rule here? Or probably have it misconfigured?
It’s a misconfiguration.
To resolve, I had to:
1) add it in the assembly references in the
Views/Web.config.2) Change the
Project > References > System.Data.EntitypropertyCopy Local=True. The assembly was not getting copied to thebinand thus identifies asmissing.