I have the following razor code:
<div class="panel panel-default col-xs-10 col-sm-10 col-md-10 col-lg-10">
<div class="panel-body">
@if (Model != null)
{
var m = Model.Requests.FileData.OrderBy(p => p.FileName);
if (m.Count() > 0)
{
foreach (var item in m)
{
if (Model.data.ToLower().Contains("dns"))
{
<div class="row">
<span>
@Html.DisplayFor(mi => item.FileName, new { @class = "form-label" })
<span class="glyphicon glyphicon-trash"></span>
</span>
</div>
}
}
}
}
</div>
</div>
This is a panel that shows uploaded files that are in the database. After selecting a file, the controller puts it in the database and then returns the partialview that has the above code.
When I debug the application and step through the above code, it does what it should do, but when I look at the html of the rendered page, the panel is empty.
Rendered page:
<div class="panel panel-default col-xs-10 col-sm-10 col-md-10 col-lg-10">
<div class="panel-body">
</div>
</div>
What am I missing here, why is the html not rendered?
[EDIT]
Break point:
I figured out that only everything in the second IF section is not rendering elements.
Using this:
<span class="form-label">@item.FileName</span>
Doesn't render anything either.
[EDIT]
Changed the viewmodel to have a property called List FileData and loaded the data in to it.
Then changed the Razor to read from it.
<div class="panel panel-default col-xs-10 col-sm-10 col-md-10 col-lg-10">
<div class="panel-body">
@if (Model != null && Model.FileData != null && Model.FileData.Any())
{
var m = Model.FileData.OrderBy(p => p.FileName);
foreach (var item in m.ToList())
{
<div class="row">
<span>
<span class="form-label">@item.FileName</span>
<span class="glyphicon glyphicon-trash"></span>
</span>
</div>
}
}
</div>
</div>
Unfortunately, still no rendering.