This the simple question but i don't know how to over come this issue I have design the webpage which get the data from the database and we can able to edit the data. But if i submit the button for save what ever i have edited it does not getting the value in the parameter.
And this is my controller
public ActionResult Movielist()
{
var movie = _context.MovieviewTable.ToList();
ViewBag.movielist = movie;
return View();
}
public ActionResult tabelForm()
{
var dropdown = _context.MovieviewTable.ToList();
var viewmodel = new MovieViewModel
{
MovieDropdownCollection=dropdown
};
return View(viewmodel);
}
public ActionResult Edit(int id)
{
var refelect = _context.MovieviewTable.SingleOrDefault(c => c.id == id);
var viewmodel = new MovieViewModel
{
movieView = refelect,
MovieDropdownCollection = _context.MovieviewTable.ToList()
};
return View("tabelForm", viewmodel);
}
[HttpPost]
public ActionResult Submitform(MovieView movie)
{
//if(movieViewModel.Movieviewdatacollection.id==0)
//{
// _context.MovieviewTable.Add();
//}
return View();
}
And this is my viewmodel
public IEnumerable<MovieView> MovieDropdownCollection
{
get;set;
}
public MovieView movieView
{
get;set;
}
And this is my View
@model Practiceupdateedit.ViewModel.MovieViewModel
@{
ViewBag.Title = "tabelForm";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>tabelForm</h2>
@using (Html.BeginForm("Submitform", "Movie"))
{
<div class="form-group">
@Html.LabelFor(m => m.movieView.MovieName)
@Html.TextBoxFor(m => m.movieView.MovieName, new { @class = "form-control" })
</div>
<div class="form-group">
@Html.LabelFor(m => m.movieView.AddedOn)
@Html.TextBoxFor(m => m.movieView.AddedOn, new { @class = "form-control" })
</div>
<div class="form-group">
@Html.LabelFor(m => m.movieView.Genere)
@Html.DropDownListFor(m => m.movieView.Genere,new SelectList(Model.MovieDropdownCollection,"Genere","Genere"), new { @class = "form-control" })
</div>
<div class="form-group">
@Html.LabelFor(m => m.movieView.Instock)
@Html.TextBoxFor(m => m.movieView.Instock, new { @class = "form-control" })
</div>
<button class="btn btn-primary">Save</button>
}
Can someone plz help me really i have spend to-much of time