Reputation: 1036
So here is my cshtml file -
@model Portal.ViewModel.DocumentViewModel
@using Portal.Helpers
@foreach (var item in Model.Documents)
{
<div id="{@item.id}linkdiv">
text
</div>
}
this loops over maybe 5-8 records and I need to uniquely identify each div
that I add.
This sample results in id's of "{2}linkdiv"
What is the syntax to get id = "2linkdiv"?
Upvotes: 0
Views: 413
Reputation: 24395
Alternative to Stephen's answer, you could reverse your naming convention:
@model Portal.ViewModel.DocumentViewModel
@using Portal.Helpers
@foreach (var item in Model.Documents)
{
<div id="[email protected]">
text
</div>
}
Upvotes: 0
Reputation: 5819
try
@model Portal.ViewModel.DocumentViewModel
@using Portal.Helpers
@foreach (var item in Model.Documents)
{
<div id="@(item.id)linkdiv">
text
</div>
}
The parents encapsulate the razor statement.
Upvotes: 2