How to show the details of a record in a view, that are different from NULL?

0

I am working on a razor view on MVC5, and I can not make it appear that I do not see the details that I leave null when I register.

Example in the image I have several questions but others were left empty because they were not necessary as I can do so that these empty fields do not appear to me.

driver. public async Task<ActionResult> Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Formularios formularios = await db.Formularios.FindAsync(id); if (formularios == null) { return HttpNotFound(); } return View(formularios); } In the view I have a table that shows me the questions:

        <table class="table table-hover table-responsive" style="width:100%">
        <thead>
            <tr>
                <th>
                    Numero
                </th>
                <th>
                    Descripcion de Pregunta.
                </th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    Pregunta 1
                </td>
                <th>
                    @Html.DisplayFor(model => model.P1)
                </th>
            </tr>
    
asked by Daniel abreu 28.06.2017 в 20:00
source

1 answer

1

You can help with linq in your query:

Formularios formularios = await db.Formularios.FindAsync(id).Where(x => x.P1 != null);

The key is in the where ...

    
answered by 28.06.2017 / 22:51
source