Hello - I'm adding a View to a new MVC project. I check the checkbox for "Create a strongly-typed view. Then I select the appropriate Model class from the dropdown. Then I select "Create" from the "Scaffold template" dropdown. The page auto-generates
as expected with textboxes for each string property in my model.
Is there a way to define my model so the scaffold template will auto-generate dropdownlists for me? Or does the .NET MVC framework require me to add dropdowns manually?
Hello - I'm adding a View to a new MVC project. I check the checkbox for "Create a strongly-typed view. Then I select the appropriate Model class from the dropdown. Then I select "Create" from the "Scaffold template" dropdown. The page auto-generates
as expected with textboxes for each string property in my model.
I think there are some scaffolding templates that know about foreign key entity relationships and will do this. Maybe not the built in ones, but Steve Sanderson built some IIRC. Personally, I never use the scaffolding stuff (since I end up removing more
of it than I'd use anyway).
dotnetterAMG123
Is there a way to define my model so the scaffold template will auto-generate dropdownlists for me? Or does the .NET MVC framework require me to add dropdowns manually?
Again (just to be pedantic), this is being done by the VS tooling (which the scaffolding is a part of) and not by the MVC framework.
dotnetterAMG...
Member
234 Points
510 Posts
how to implement dropdowns in mvc?
Jul 05, 2012 12:24 AM|LINK
Hello - I'm adding a View to a new MVC project. I check the checkbox for "Create a strongly-typed view. Then I select the appropriate Model class from the dropdown. Then I select "Create" from the "Scaffold template" dropdown. The page auto-generates as expected with textboxes for each string property in my model.
Is there a way to define my model so the scaffold template will auto-generate dropdownlists for me? Or does the .NET MVC framework require me to add dropdowns manually?
BrockAllen
All-Star
27544 Points
4907 Posts
MVP
Re: how to implement dropdowns in mvc?
Jul 05, 2012 01:30 AM|LINK
I think there are some scaffolding templates that know about foreign key entity relationships and will do this. Maybe not the built in ones, but Steve Sanderson built some IIRC. Personally, I never use the scaffolding stuff (since I end up removing more of it than I'd use anyway).
Again (just to be pedantic), this is being done by the VS tooling (which the scaffolding is a part of) and not by the MVC framework.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
bkis1112
Participant
1061 Points
226 Posts
Re: how to implement dropdowns in mvc?
Jul 05, 2012 02:20 AM|LINK
There many thread in forum answer your question: http://forums.asp.net/t/1818798.aspx/1?Populate+a+DropDownList+in+MVC+2
http://forums.asp.net/t/1817879.aspx/1?how+to+bind+dropdown+in+mvc+razor
http://forums.asp.net/t/1817301.aspx/1?Creating+a+drop+down+list+on+MVC+view+populated+from+table+data
take a look at my post in each above thread
thanks for reading my post
Trần Lê Thành Trung