Here is my razor view.
@model IEnumerable<ApricaROI.Models.DatabaseEntities.SalesItemMapping>
@{
var name_List = Model.GroupBy(x => x.Name).Select(y => y.First()).ToList();
}
@foreach (var name in Model.Select(item => item.Name).Distinct()) {
<div id="item@@name" class='itemDivs'>
@{ Html.RenderPartial("_EditItemChild",
Model.Where(item => item.Name== name).ToList()); }
</div>
}
I don't know what kind of error it has. It is giving following error.
"\"@\" is not valid at the start of a code block.
Only identifiers, keywords, comments, \"(\" and \"{\" are valid.\r\n"
I have read somewhere that @@
works in mvc3
i.e. razor 1.0
. But somehow doesnt work in mvc4 razor-2.0
So try Changing
<div id="item@@name" class='itemDivs'>
to
<div id="item@("@name")" class='itemDivs'>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With