@if (@Model.Persons.Count > 0)
var data= @Model.Persons;
}
else
{
<b>no data!</b>
}
when I add foreach statement inside if statement else block of code become broken
@if (@Model.Persons.Count > 0)
{
var data= @Model.Persons;
foreach(var item in @data){
...
}
}
else{ // this now becomes broken after adding foreach
}
@from data in the foreach line?@ifor a tag like a @foreach (these kind of helpers), when you got a block with brackets just below it, you're in c# code, so the@befor Model and especially here, befor data, is useless. Try it !