vendredi 3 juin 2016

ASP.net MVC use checkbox value als bool in HTML code

I want to use the checkbox value in the code in the view. This is the part where I check if the product is available, when it is available it wil be added to the table. When the checkbox is checked a product which isn't available will be added too.

I have searched for possible solutions but everytime I get stuck, not knowing what to do. Can somebody help me with this?

<div class="checkbox">
<label><input id="UnavailableProducts" name="UnavailableProducts" value="true" type="checkbox" />Laat niet beschikbare artikelen zien</label>
</div>

<div class="panel panel-default" style="margin-top: 25px; margin-bottom: 25px; min-width: 330px">
<!-- Default panel contents -->
<div class="panel-heading">Artikelen</div>
<!-- Table -->
<table class="table table-responsive">
    <thead>
        <tr>
            <th>#</th>
            <th>Artikelnr</th>
            <th>Omschrijving</th>
            <th>Aantal</th>
        </tr>
    </thead>
    <tbody>
        @{
            if (Model != null)
            {
                DataFound = true;
                int count = 0;
                foreach (Article a in Model)
                {
                    if (a.Available == true)
                    {
                        count++;
                        <tr class='clickable-row' data-url="@Url.Action("ArticleDetail", "Article", new { articleNumber = a.ArticleNumber} )">
                            <th scope="row">@count.ToString()</th>
                            <td>@Html.Encode(a.ArticleNumber)</td>
                            <td style="word-wrap: break-word;min-width: 50px;max-width: 160px;">@Html.Encode(a.Summary)</td>
                            <td>@Html.Encode(a.Stock)</td>
                        </tr>
                    }
                }
            }
            else
            {
                DataFound = false;
            }
        }
    </tbody>
</table>




Aucun commentaire:

Enregistrer un commentaire