I want to show a div if the asociated model has data after OnPost. What I tried is
- @if (Model.HazIds != null)
- {
- "HazardIdentification">
class
="text-lg-left text-primary pl-1 mt-1 mb-1" style="font-size:24px">Hazard Identificationclass="row no-gutters">class="col-3">- ="NameGT" class="form-control badge-primary">Hazard Class
class="col-3">- ="EquipmentUsed" class="form-control badge-primary">Hazard Detail
class="col-3">- ="Oxygen" class="form-control badge-primary">Hazard Protective Measure Class
class="col-3">- ="LEL" class="form-control badge-primary">Hazard Protective Measure Detail
- @foreach (var item1 in Model.HazIds)
- {
class="row no-gutters">class="col-3">- class="form-control" style="font-size:12px;">@Html.DisplayFor(modelItem => item1.HazClass)
class="col-3">- class="form-control" style="font-size:12px;">@Html.DisplayFor(modelItem => item1.HazDetails)
class="col-3">- class="form-control" style="font-size:12px;">@Html.DisplayFor(modelItem => item1.HazPMClass)
class="col-3">- class="form-control" style="font-size:12px;">@Html.DisplayFor(modelItem => item1.HazPMDetails)
- }
- }
but is not giving then results expected. If I use !=null it shows the div content (labels) even when model has no data; if I use ==null it does not show anything even if the model has data
HazIds is an IList model containing int and strings

Sachin SinghPosted Nov 24, 2020, 12:20 PM
Marius VasilePosted Nov 25, 2020, 2:47 AM
Ashutosh GuptaPosted Nov 25, 2020, 12:17 AM