Controller:
using (ISession session = NHIbernateSession.OpenSession())
{
var item = session.Query<CarModel>().ToList();
ViewBag.Modas = item;
return View();
}
View:
<div class="form-group">
@Html.LabelFor(model => model.Modelis.model_name, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.Modelis.Id, new SelectList(ViewBag.Modas, "Id", "model_name"), "--Select Cars--")
</div>
</div>
Controller(submition part):
[HttpPost]
public ActionResult Create(Transport item)
{
try
{
using (ISession session = NHIbernateSession.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Save(item);
transaction.Commit();
}
}
return RedirectToAction("Index");
}
catch (Exception exception)
{
return View();
}
}
And I get error on submit:
Value cannot be null. Parameter name: items
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: items
And I don't understand what is wrong