How to populate drop down with a database result in mvc linq EF?

I'm assuming that you have a MatchTypes table in your database that has Id filed and Description field. You want to display a drop down that will show different MatchType descriptions.

Up vote 1 down vote favorite share g+ share fb share tw.

Here is my Controller: public class MatchManagerController : Controller { // // GET: /MatchManager/ public ActionResult Index() { return View(); } public ActionResult CreateMatch() { return View(); } } Here is my View: @model MatchGaming.Models. MatchModel @{ ViewBag. Title = "CreateMatch"; } CreateMatch @using (Html.BeginForm()) { @Html.

ValidationSummary(true) MatchModel @Html. LabelFor(model => model. MatchName) @Html.

EditorFor(model => model. MatchName) @Html. ValidationMessageFor(model => model.

MatchName) @Html. LabelFor(model => model. MatchDescription) @Html.

EditorFor(model => model. MatchDescription) @Html. ValidationMessageFor(model => model.

MatchDescription) @Html. LabelFor(model => model. Wager) @Html.

EditorFor(model => model. Wager) @Html. ValidationMessageFor(model => model.

Wager) @Html. LabelFor(model => model. MatchTypeId) @Html.

EditorFor(model => model. MatchTypeId) @Html. ValidationMessageFor(model => model.

MatchTypeId) } @Html. ActionLink("Back to List", "Index") I want my MatchTypeId to be a drop down that populates from my table MatchTypes. C# asp.net asp.net-mvc-3 link|improve this question asked Mar 16 '11 at 2:46anthonypliu1,132721 73% accept rate.

I'm assuming that you have a MatchTypes table in your database that has Id filed and Description field. You want to display a drop down that will show different MatchType descriptions. Include a field in you model that returns collection of MatchTypes records from the MatchTypes table.

Then instead of LabelFor do this: @Html. DropDownListFor(m => m. Description, Model.

MatchTypes).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions