Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The data is not being passed from Index.cshtml back to HomeController.cs.

The data is populated initially into the table correctly (code omitted for brevity).

The "@Url.Action("Delete", new{ testID = item.testID }) is not returning the data back to the controller.

Index.cshtml
HTML
@model MDFtoMVCdelete.Models.DeleteModel

<center>
    <table>
        @foreach (var item in Model.thistable)
        {
             <tr><td>@item.testID</td><td>@item.datetime</td><td>@item.col1</td><td>@item.col2</td><td>@item.col3</td><td><form action="@Url.Action("Delete", new{ testID = item.testID })" method="delete"><input type="submit" value="Delete" /></form></td></tr>
        }
    </table>
</center>

HomeController.cs
SQL
public ActionResult Delete(int testID)
        {
            //code omitted for brevity
            return View();
        }

Errorcode:
The parameters dictionary contains a null entry for parameter 'testID' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Delete(Int32)' in 'MDFtoMVCdelete.Controllers.HomeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters 
Posted
Comments
SrikantSahu 14-Jan-15 13:09pm    
you should change the input parameter to int? instead of int, this makes it nullable.

1 solution

First check if any value is getting binded to your action for parameter testid.
And if you just want to show some delete links why to use form tag, you can do it by using links too.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900