Reading from here: ASP.NET MVC
Action SelectCategory has been created inside controller -
public ActionResult SelectCategory() {
A painless way for data binding to bind data to the model: Do not use the razor for Dropdown. Bind it manually, get it with FormCollection object.
Controller:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(Sorun sorun,FormCollection fc)
{
//Define independently as form collection
sorun.GonderilecekBirim = fc["GonderilecekBirim"];
sorun.IlkSorulmaTarihi = DateTime.Now;
if (ModelState.IsValid)
{
db.Soruns.Add(sorun);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(sorun);
}
View
@Html.LabelFor(model => model.GonderilecekBirim, htmlAttributes: new { @class = "control-label col-md-2" })
@*@Html.ValidationMessageFor(model => model.GonderilecekBirim, "", new { @class = "text-danger" })*@