6
Answers

Edit link passing null value when click on that link

Hi,
In my view code I have written code for editing a record
 
<td> @Html.ActionLink("Edit", "Edit","PO", new { id = item.Sl_No }) |
@Html.ActionLink("Details", "Details", new { id = item.Tracking }) </td>
<td>@item.Tracking</td>
<td>@item.Project_No</td>
<td>@item.Project_Phase</td>
<td>@item.Project_No_Description</td>
<td>@item.Requester</td>
<td>@item.Date_Requested</td>
 
When loading the data I am able to see the fields mentioned in the script,
But In controller code
 
public ActionResult Edit(int SlNo)
{
var viewModel = new POViewModel();
viewModel.Order = PODb.orders.Single(x => x.Sl_No == SlNo);
viewModel.Order = (order)PODb.orders.Where(x => x.Sl_No == SlNo);
return View(viewModel);
}
 
Here In the above code I am getting the parameter value as null as it is throwing the below exception
"

The parameters dictionary contains a null entry for parameter 'SlNo' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Edit(Int32)' in 'PurchaseOrder.Controllers.POController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters

 Could any one please help me how to rectify this one?

Answers (6)

0
Photo of haan jae
NA 22 19.1k 13y
ok, thanks for the link, definitely will look on it, but if anyone have any others useful information please kindly tell me as well.

Thank you.
0
Photo of Prabhu Raja
NA 4.7k 1.5m 13y
Hi haan,

 you may try this. Click Here

-
-------------------------------------------------
If this post helps you, then mark as "Correct Answer"
Thank You