开发者

Error while running MVC Application including JQuery Grid Plugins

I am getting the following error while 开发者_StackOverflow社区running my MVC Application that consists of the jquery grid plugins.

The parameters dictionary contains a null entry for parameter 'page' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult GetCategory(System.String, System.String, Int32, Int32)' in 'ecom.Controllers.AdminController'. To make a parameter optional its type should be either a reference type or a Nullable type.
Parameter name: parameters

public ActionResult GetCategory(string sidx, string sord, int page, int rows)
{
    var jsonData = _Category.GetAll().ToJsonForjqGrid("category_id", new[] { "category_id", "category_name" });
    return Json(jsonData);
}

In the getCategory view I am using it in this way:

<script language="javascript" type="text/javascript">

        loadProducts();

</script>


You have an action GetCategory with int parameters, but you don't specify the value for the parameters when you call this action.

As the exception suggests, you should make the int parameters nullable if the parameters are optional and test if the parameter has a value in the action.

public ActionResult GetCategory(string p1, string p2, int? p3, int? p4) 
{
  if (!p3.HasValue)
    throw new ArgumentNullException("p3");
  //etc...
}

If the parameter is not optional, you have an error in the calling code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜