I'm trying to delete an entry from the database. This is my controller method:
public ActionResult Delete(Models.CommentEntry entry)
{
_db.Entries.Remove(entry);
_db.SaveChanges();
return RedirectToAction("Index");
}
And this is my .cshtml:
@foreach (var entry in ViewBag.Entries)
{
<section class="contact">
<header>
<h3>@entry.Message</h3>
</header>
<p>
Posted by @entry.Name on @entry.DateAdded.ToLongDateString()
</p>
</section>
<form method="post" action="Delete">
<input type="submit" value="Delete" class="btn btn-danger" />
</form>
}
This is how it looks right now. As you can see i want whenever the user presses delete, to delete the corresponding comment. I'm using foreach to access them all and was hoping that this way I can pass the comment object to the controller.

As you can see the object doesn't get passed down and always has initial values, therefore i'm getting a dump. Where is my mistake?
Thank you.
