Problem with creating Grid Control

Jul 15, 2011 at 12:16 PM

Hi! I want to create Grid Control like it was in the example.

http://mvcjquerycontrols.codeplex.com/wikipage?title=MVC.Controls%20Tutorial%20%232&version=2

I've done all the same, but I have this error:

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

How can I fix it?

Coordinator
Jul 15, 2011 at 12:25 PM

Hi,

Could you post your controller action?

And please look at the example project for up to date code samples - I'm sorry but the tutorial in the documentation tab is out dated (I'll update it in the next couple of days)

Jul 15, 2011 at 12:52 PM

Ok. Now I'm trying to do like in MVC.Controls.Examples from there http://mvcjquerycontrols.codeplex.com/releases/view/67374.  Is it up to date?

 ProductController:

 public ActionResult List(SearchModel searchModel)
{
TopicRepository repository = new TopicRepository();

List<Product> products = repository.ListAll();

var model = products.AsQueryable();
return Json(model.ToGridData(searchModel, new[] { "Id", "Name", "CompanyName", "Price" }), JsonRequestBehavior.AllowGet);
}

List.cshtml:
@using MVC.Controls.Grid

@Html.Grid(new GridControl().SetName("grid")
.SetPageSize(10)
.SetIsAutoSize(true)
.SetHttpVerb(HttpVerbs.Get)
.SetListUrl("Product/List")
.SetColumns<MvcApplication4.Models.Product>(cs =>
{
                cs.Add(x => x.ProductId).SetAsPrimaryKey();
                cs.Add(x => x.Name);
                cs.Add(x => x.CompanyName);
                cs.Add(x => x.Price);
            }))

And now I have such error:

Object reference not set to an instance of an object.

 

Coordinator
Jul 15, 2011 at 1:37 PM

Can you post the full stack-trace so we could try and find the source of the error?