I am creating a bunch of <div> elements using a foreach loop with Razor syntax. Right now I have this:
@foreach (var item in Model)
{
    <div class="grid_6 listColumn" id="[email protected]">
    ...
    </div>
}
Basically I want the div identifiers to be labeled by the value in item.TeamID like:
team_1 team_2 team_3
The syntax I currently have doesn't recognize the code portion. I also tried id="team_@:item.TeamID" but it throws an error. However, id="team_ @item.TeamID" works fine, but I don't want that space in there. I'm pretty new to Razor, is there an easy way to do this?
Try this:
<div class="grid_6 listColumn" id="@("team_" + item.TeamID)">
    ...
</div>
                        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