@for(int i = 0; i < this.Model.PresetReports.Count; i++) {
@{ var preset = this.Model.PresetReports.ElementAt(i); }
<a href="#" class="@(i == 0 ? "selected" : string.Empty)">@preset.Label</a>
}
It says that 'preset' does not exist in the current context. ?? Thanks!
Try like this:
@for(int i = 0; i < this.Model.PresetReports.Count; i++)
{
var preset = this.Model.PresetReports.ElementAt(i);
@<a href="#" class="@preset.class">@preset.Label</a>
}
but I really don't see why you wouldn't use a foreach loop which would make a little more sense in your scenario:
@foreach (var preset in Model.PresetReports)
{
@<a href="#" class="@preset.class">@preset.Label</a>
}
Now this being said I have some doubts about preset.class. You really have a property called class (with lowercase c which is a reserved word in C#) on your view model?
@for(int i = 0; i < this.Model.PresetReports.Count; i++) {
var preset = this.Model.PresetReports.ElementAt(i);
<a href="#" class="@preset.class">@preset.Label</a>
}
That does it.
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