Open vanithav opened 9 years ago
The BMVC's .DropDownList(string,string)
is using the regular MVC's .DropDownList(string,string)
, under the hood. I'm not sure about the use of foreign keys to populate drop downs though.
My model looks like this. public class Module { public int ID { get; set; }
[StringLength(25)]
[Required(AllowEmptyStrings = false, ErrorMessage = "Name is required.")]
public String Name{ get; set; }
[ForeignKey("ModuleType")]
[Required(AllowEmptyStrings = false, ErrorMessage = "Module Type is required.")]
public int ModuleTypeId { get; set; }
public ModuleType ModuleType { get; set; }
}
public class ModuleType
{
public int ID { get; set; }
[StringLength(25)]
public String Name { get; set; }
}
And when i use @Html.DropDownList("ModuleTypeId", "--Select--") in the view it loads the data from ModuleType Table.
But when i use @f.FormGroup().DropDownList("ModuleTypeId", "--Select--")
It throws me error. System.NullReferenceException: Object reference not set to an instance of an object.
is that EntityFramework that's doing it? I'm not familiar with it :/
I can use the below which renders a drop down and populated the value automatically based on the foreignKey "ModuleTypeId". @Html.DropDownList("ModuleTypeId", "--Select--")
What is the equivalent in Twitter BMVC. I do not want to create a method or property that will return List(SelectListItem). How do i use the below method. FormGroup().DropDownList(string,string)