开发者

How to use html.grid control in spark view for asp.net mvc?

class person()
{
   public int Id{get;set;}
   public string Name{get;set;}
}

HomeController.cs

ActionResult Index()
{
   IList list=new[]{   
            new person { Id = 1, Name = "Name1" }, 
            new person { Id = 2, Name = "Name2" }, 
            new person { Id开发者_开发技巧 = 3, Name = "Name3" } 
            };
   ViewData["mygrid"]=list;
   return view();
}

Home\Index.spark

!{Html.Grid[[person]]("mygrid",
      (column=>{
      column.For(c=>c.Id);
      column.For(c=>c.Name);
  }))

Am getting the error

Dynamic view compilation failed..error CS1501: No overload for method 'Grid' takes '2' arguments.

I have added reference to MvcContrib.dll And added following namespace in the _global.spark file

<use namespace="MvcContrib.UI"/>
<use namespace="MvcContrib.UI.Grid"/>
<use namespace="MvcContrib.UI.Pager"/>
<use namespace="MvcContrib.UI.Grid.ActionSyntax"/>
<use namespace="Microsoft.Web.Mvc.Controls"/>

I want to bind the data to my grid in spark view.Can anybody help.


Should it be

!{Html.Grid[[person]]("mygrid").Columns(
  column=>{
      column.For(c=>c.Id);
      column.For(c=>c.Name);
  })}

? Notice .Columns().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜