Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a small problem. My problem is that I am making a capture form with MVC 4 and want a drop down list to bind the users to it, it must then populate on form load from the users table but when i save data it must then write to a different table.

here is my code below:

@model CCICoaching.Models.Data_AgentCaochCapture
@Model CCICoaching.Models.DropDownList
@{
ViewBag.Title = "Create";
}

Create



@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)


Data_AgentCaochCapture

@Html.DropDownList("UserID", (IEnumerable<SelectListItem>)ViewBag.User)


@Html.LabelFor(model => model.UserName)


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



@Html.LabelFor(model => model.AgentName)


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



@Html.LabelFor(model => model.CaptureDate)


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



@Html.LabelFor(model => model.RAG38Day)


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



@Html.LabelFor(model => model.RAGBetterDeal)


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



@Html.LabelFor(model => model.RAGTech)


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



@Html.LabelFor(model => model.RAGCSB)


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



@Html.LabelFor(model => model.BrightStart)


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



@Html.LabelFor(model => model.MakeConnection)


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



@Html.LabelFor(model => model.IsolateAndFix)


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



@Html.LabelFor(model => model.AddValue)


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



@Html.LabelFor(model => model.BrightEnding)


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



@Html.LabelFor(model => model.MetPreviousObjective)


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



@Html.LabelFor(model => model.Goal)


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



@Html.LabelFor(model => model.GoalType)


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



@Html.LabelFor(model => model.Reality)


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



@Html.LabelFor(model => model.Options)


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



@Html.LabelFor(model => model.WillOrWayForward)


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



@Html.LabelFor(model => model.Rebuttal)


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



@Html.LabelFor(model => model.CF)


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



@Html.LabelFor(model => model.UnexplainedSilence)


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



@Html.LabelFor(model => model.CorrectHoldProcess)


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



@Html.LabelFor(model => model.IncorrectNotes)


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



@Html.LabelFor(model => model.Incorrectransfer)


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



@Html.LabelFor(model => model.GoodCall)


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



@Html.LabelFor(model => model.CallAvoidance)


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



@Html.LabelFor(model => model.TVQAsked)


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



@Html.LabelFor(model => model.CreditsOffered)


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



@Html.LabelFor(model => model.WeeklyCoachPlanFollowed)


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



@Html.LabelFor(model => model.OTDStartOfWeek)


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



@Html.LabelFor(model => model.OTDEndOfWeek)


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



@Html.LabelFor(model => model.RAG)


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



@Html.LabelFor(model => model.CoachPlanFollowed)


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



@Html.LabelFor(model => model.NextSteps)


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



@Html.LabelFor(model => model.Notes)


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



<input type="submit" value="Create" />



}


@Html.ActionLink("Back to List", "Index")


@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Posted

1 solution

Visit this page. This is direct solution you your case:

MVC4 Bind DropDown
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900