I am learning MVC4 and Framework 5. I am trying to do something that has me stumped.
Let's say we are building a sandwich app. The app allows a customer to choose any two ingredents from a list (ham & cheese, PB & jelly, turkey & mayo, etc) as Ing1 and Ing2. I need for the view to have 2 dropdown lists, onr for Ing1 and one for Ing2, both
pointing at the ingredients table. Sort of like this:
public class Ingredient
{
public int ID { get; set; }
public string Description { get; set; }
}
public class Sandwiches
{
public int ID { get; set; }
public virtual Ingredient Ing1 { get; set; }
public virtual Ingredient Ing2 { get; set; }
}
This model does not produce a dropdown filled with Ingredients for Ing1 and another one for Ing2 when the controller is scaffolded.
davecove
0 Points
2 Posts
Two virtual fields?
Aug 20, 2012 04:02 AM|LINK
I am learning MVC4 and Framework 5. I am trying to do something that has me stumped.
Let's say we are building a sandwich app. The app allows a customer to choose any two ingredents from a list (ham & cheese, PB & jelly, turkey & mayo, etc) as Ing1 and Ing2. I need for the view to have 2 dropdown lists, onr for Ing1 and one for Ing2, both pointing at the ingredients table. Sort of like this:
public class Ingredient { public int ID { get; set; } public string Description { get; set; } } public class Sandwiches { public int ID { get; set; } public virtual Ingredient Ing1 { get; set; } public virtual Ingredient Ing2 { get; set; } }This model does not produce a dropdown filled with Ingredients for Ing1 and another one for Ing2 when the controller is scaffolded.
How can I get that result?
Thank you for your time,
Dave
francesco ab...
All-Star
20954 Points
3286 Posts
Re: Two virtual fields?
Aug 20, 2012 07:50 AM|LINK
scaffolding is just a starting point, then you have to modify the code created as needed
Mvc Controls Toolkit | Data Moving Plug-in Videos