I am binding my DDL with tempdata which is basically all username and userid as shown below.
<div class="form-group">
@Html.LabelFor(model => model.AssignedTo, "Assigned To : ", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("UserID", TempData["UserList"] as SelectList, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.ValidationMessageFor(model => model.AssignedTo, "", new { @class = "text-danger" })
</div>
</div>
In controller I am trying to fetch value like below.
public ActionResult Create(WMTProjects prj)
{
prj.AssignedTo
where I am getting value as 0, and I was supposed to get corresponding user's userid.
I was all working fine till i changed from
@using (Html.BeginForm("Create", "CreateProjects", FormMethod.Post, new { id = "FormId" }))
to
@using (Html.BeginForm())
and changed my button attributes to
<input type="submit" value="Create" formaction="Create" formmethod="post" class="btn btn-default" />
Not sure what's wrong in this approach.