【问题标题】:How to use html.grid control in spark view for asp.net mvc?如何在 asp.net mvc 的火花视图中使用 html.grid 控件?
【发布时间】:2010-05-27 13:07:12
【问题描述】:
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();
}

首页\Index.spark

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

我得到了错误

动态视图编译失败..错误 CS1501:方法 'Grid' 没有重载需要 '2' 个参数。

我添加了对 MvcContrib.dll 的引用 并在 _global.spark 文件中添加了以下命名空间

<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"/>

我想在 spark 视图中将数据绑定到我的网格。谁能帮忙。

【问题讨论】:

    标签: spark-view-engine


    【解决方案1】:

    应该是

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

    ?注意 .Columns()。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-17
      • 1970-01-01
      相关资源
      最近更新 更多