C# 如何在MVC中为@Html.Grid行添加Id?

C# 如何在MVC中为@Html.Grid行添加Id?,c#,asp.net-mvc,asp.net-mvc-4,razor,nopcommerce,C#,Asp.net Mvc,Asp.net Mvc 4,Razor,Nopcommerce,如何在MVC中为@Html.Grid添加Id字段,下面给出了我的代码 @Html.Grid(Model).Columns(column => { column.For(rph => rph.SpecificationAttributeOption).Named("").Attributes(style => "width:70%;"); }).Attributes(style => "width: 100%; bord

如何在MVC中为@Html.Grid添加Id字段,下面给出了我的代码

  @Html.Grid(Model).Columns(column =>
       {
           column.For(rph => rph.SpecificationAttributeOption).Named("").Attributes(style => "width:70%;");
       }).Attributes(style => "width: 100%; border: 0px").RowStart((row) =>
       {
           if (row.IsAlternate) { return "<tr style=''>"; }
           else { return "<tr>"; }
       })
@Html.Grid(Model).Columns(column=>
{
column.For(rph=>rph.SpecificationAttributeOption).Named(“”).Attributes(style=>“宽度:70%;”);
}).Attributes(样式=>“宽度:100%;边框:0px”).RowStart((行)=>
{
if(row.IsAlternate){return”“;}
else{return”“;}
})

我不能把这归功于我,但我可以肯定地把我找到的一个传给你。似乎可以/应该通过“HTML属性”设置添加ID,如
new{ID=“someIDWhichIset”}

请参阅StackOverflow答案。

@Html.Grid(Model).Columns(column=>{}).Attributes(id=>“您选择的id”)