我正在使用 Grid.MVC(https://gridmvc.codeplex.com/),我需要在同一视图中为网格渲染网格和 CRUD。
@model IEnumerable<Grid.Models.Catagory>
...
...
@Html.Grid(Model).Columns(columns =>
{
columns.Add()
.Encoded(false)
.Sanitized(false)
.Titled("CatagoryName").RenderValueAs(o => RenderCatagoryName("CatagoryName", o.CatagoryName));
columns.Add()
.Encoded(false)
.Sanitized(false)
.Titled("Color").RenderValueAs(o => RenderCatagoryName("Color", o.Color));
columns.Add()
.Encoded(false)
.Sanitized(false)
.Titled("Print Template").RenderValueAs(o => RenderCatagoryName("Print Template", o.PrintTemplate));
}
我的控制器
public ActionResult Index()
{
return View(clients);
}
这很好用,但是当我需要在同一个视图中插入时,我无法使用相同的模型,因为它是一个 IEnumerable 类型。
--Insert values--
//couldn't use the model for insert directly since it is a list type
@Html.LabelFor(m => m.)
@Html.TextBoxFor(m => m., new { maxlength = 50 })
我的视图模型
public class Catagory
{
public int CatagoryID { get; set; }
public string CatagoryName { get; set; }
public string Color { get; set; }
public string PrintTemplate { get; set; }
public string Language { get; set; }
}
有没有办法为 Grid.MVC 和插入操作使用相同的视图