[英]MVCContrib Grid and nun-nullable parameter
I'm using the MVCContrib Grid. 我正在使用MVCContrib网格。 My controller action accepts 3 parameters, the sortoptions and paging parameter for the grid, and a ResourceID parameter, that specifies which resource you want to view bids for.
我的控制器操作接受3个参数,即网格的sortoptions和分页参数,以及ResourceID参数,该参数指定要查看其出价的资源。
When i click on the links i get the following error 当我单击链接时,出现以下错误
The parameters dictionary contains a null entry for parameter 'ResourceId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult ByResource(Int32, MvcContrib.UI.Grid.GridSortOptions, System.Nullable`1[System.Int32])' in 'TaskingApp.Controllers.BidController'.
参数字典包含方法'System.Web.Mvc.ActionResult ByResource(Int32,MvcContrib.UI.Grid.GridSortOptions,System.Nullable`1 []的非空类型'System.Int32'的参数'ResourceId'的空条目。 System.Int32])”中的“ TaskingApp.Controllers.BidController”。 An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
可选参数必须是引用类型,可为空的类型,或者必须声明为可选参数。
How do i pass in the ResourceId Parameter in properly? 如何正确输入ResourceId参数?
Here is my Controller action 这是我的控制器动作
//Get bids by resource
public ActionResult ByResource(int ResourceId,GridSortOptions sort, int? page)
{
var bids = bidRepo.GetUpcomingBidsByResource(ResourceId);
if (sort.Column != null)
bids = bids.OrderBy(sort.Column, sort.Direction);
ViewData["sort"] = sort;
return View("Index", bids.AsPagination(page ?? 1, 15));
}
And here's the actionlink 这是动作链接
<%= Html.ActionLink(item.ResourceName, "ByResource", new { id = item.ResourceID })%>
The specified property must match the controllers property name: 指定的属性必须与控制器的属性名称匹配:
new { ResourceId = item.ResourceID }
That, or change your method signature to the following: 或将您的方法签名更改为以下内容:
ByResource(int id, GridSortOptions sort, int? page)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.