Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 25, 2012 08:17 PM by dragonworrier
Member
5 Points
30 Posts
Apr 25, 2012 11:54 AM|LINK
Hi,
I am using Html.DropDownListFor() to show drop down list values, the code is as follows.
<%:Html.DropDownListFor(m => m.CurrentBoat.ID , new SelectList(Model.Boats, "ID", "Name" , Model.CurrentBoat.ID), new { id = "cmbB", @class = "formOption", style = "width:140px;" })%>
it shows the text only is "Name" field from DB, i want to show here, combination of two fields from DB, For example i want to show
Name / SNumber
here "Name" and "SailNumber" are two different fields in my DB.
How can i show them according to my requirements???
Thanks in Advance
All-Star
27534 Points
4907 Posts
MVP
Apr 25, 2012 11:59 AM|LINK
Use a view model or add a property to the model which is your "display property".
Apr 25, 2012 08:17 PM|LINK
Thanks for help
dragonworrie...
Member
5 Points
30 Posts
How to show two values in Drop Down list text in MVC
Apr 25, 2012 11:54 AM|LINK
Hi,
I am using Html.DropDownListFor() to show drop down list values, the code is as follows.
<%:Html.DropDownListFor(m => m.CurrentBoat.ID , new SelectList(Model.Boats, "ID", "Name" , Model.CurrentBoat.ID),
new { id = "cmbB", @class = "formOption", style = "width:140px;" })%>
it shows the text only is "Name" field from DB, i want to show here, combination of two fields from DB, For example i want to show
Name / SNumber
here "Name" and "SailNumber" are two different fields in my DB.
How can i show them according to my requirements???
Thanks in Advance
http://webdesignpluscode.blogspot.com/
BrockAllen
All-Star
27534 Points
4907 Posts
MVP
Re: How to show two values in Drop Down list text in MVC
Apr 25, 2012 11:59 AM|LINK
Use a view model or add a property to the model which is your "display property".
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
dragonworrie...
Member
5 Points
30 Posts
Re: How to show two values in Drop Down list text in MVC
Apr 25, 2012 08:17 PM|LINK
Thanks for help
http://webdesignpluscode.blogspot.com/