(it's a simple phonebook project)i want to delete a row in a list (a contact from a notebook) and when user presses delete button i want to show it's information and get a confirmation from user here is view code
@model Project1.Models.EF_Model.Phone_book
@{
ViewBag.Title = "Delete";
}
<h2>Delete</h2>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>Product</h4>
<hr />
<dl class="dl-horizontal">
<tr>
<dt>
@Html.DisplayNameFor(model => model.First_Name)
</dt>
<td>
@Html.DisplayFor(model => model.First_Name)
</td>
<dt>
@Html.DisplayNameFor(model => model.Last_Name)
</dt>
<dd>
@Html.DisplayFor(model => model.Last_Name)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Number)
</dt>
<dd>
@Html.DisplayFor(model => model.Number)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Email)
</dt>
<dd>
@Html.DisplayFor(model => model.Email)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Address)
</dt>
<dd>
@Html.DisplayFor(model => model.Address)
</dd>
</tr>
</dl>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-actions no-color">
<input type="submit" value="Delete" class="btn btn-default" /> |
@Html.ActionLink("Back to List", "Index")
</div>
}
</div>
and in my controller i chek the basics and send id to the model to get it deleted
[HttpGet]
public ActionResult Delete(int? _id)
{
return View();
}
#endregion
#region [- Post -]
[HttpPost]
public ActionResult Delete(int _id)
{
if (ModelState.IsValid)
{
Ref_ViewModel = new ViewModel.ViewModel();
Ref_ViewModel.Delete(_id);
}
else
{
ViewBag.Massage = "Choose a Contact";
}
return View();
}
how can i show my selected data in my confirmation view?
when i press the button to delete it and also i recieve this error
The parameters dictionary contains a null entry for parameter '_id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Delete(Int32)' in 'Project1.Controllers.HomeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters
when i press the button to delete it,i guess it returns null value or i have to do some thing with routconfig,pls help me i'm i'm working o it for 2 days(U should know that i've just started learning mvc )