Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET MVC-ExpressionHelper.GetExpressionText:返回错误的属性名称_C#_Asp.net_Asp.net Mvc_Expression_Mvccontrib - Fatal编程技术网

C# ASP.NET MVC-ExpressionHelper.GetExpressionText:返回错误的属性名称

C# ASP.NET MVC-ExpressionHelper.GetExpressionText:返回错误的属性名称,c#,asp.net,asp.net-mvc,expression,mvccontrib,C#,Asp.net,Asp.net Mvc,Expression,Mvccontrib,我的视图使用MVCContrib网格,其中需要一些输入字段: @(Html.Grid(Model.Items) .RenderUsing(new PostAsListRenderer<ItemModel>("list")) .Columns(c => { c.Custom( @<text> @Html.HiddenFor(x => item.Id), item.Id) @item.Id

我的视图使用MVCContrib网格,其中需要一些输入字段:

@(Html.Grid(Model.Items)
.RenderUsing(new PostAsListRenderer<ItemModel>("list"))
.Columns(c =>
{
    c.Custom(
        @<text>
             @Html.HiddenFor(x => item.Id), item.Id)
             @item.Id
         </text>
    ).Named("Id");
    c.For(x => Html.TextBoxFor(y => x.Name)).Named("Name");
    c.For(x => Html.TextBoxFor(y => x.Description)).Named("Description");
    c.For(x => Html.DropDownListFor(y => x.SelectedItem, Model.SelectListItems)).Named("DropDown");
    c.For(x => Html.NameFor(y => x.Name));
}))
有没有更好的方法来创建正确的名称属性值

编辑#1:

在我看来,这是一个错误。如果您也这么认为,请在以下位置投票支持该问题:

编辑#2: 这些是我的视图模型:

public class ViewModel
{
    public List<ItemModel> Items { get; set; }
    public List<SelectListItem> SelectListItems { get; set; }
}

public class ItemModel
{
    public int Id { get; set; }
    public string SelectedItem { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
}
公共类视图模型
{
公共列表项{get;set;}
公共列表SelectListItems{get;set;}
}
公共类项目模型
{
公共int Id{get;set;}
公共字符串SelectedItem{get;set;}
公共字符串名称{get;set;}
公共字符串说明{get;set;}
}

代码也可以从以下网址获得:

您的模型类看起来像什么?@DanielA.White我已经更新了我的问题。
public class ViewModel
{
    public List<ItemModel> Items { get; set; }
    public List<SelectListItem> SelectListItems { get; set; }
}

public class ItemModel
{
    public int Id { get; set; }
    public string SelectedItem { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
}