0
@model IEnumerable<WIMMPortalServer.BAL.DTO.GlobalCodeDTO>
@foreach (var item in Model)
{
    if (@item.GlobalCodeCategoryValue == "115")
    {
        <div class="form-group">
            @*<h6 >PICTURE FORMAT:</h6>*@
            <h6>@item.GlobalCodeCategoryName</h6>
            <div class="checkboxs round">
                <div class="element">
                    <label id="lblcolor">
                    @*COLOR*@
                    @item.GlobalCodeName
                    <input type="checkbox" name="closed" value="closed">
                    <span class="checkmark"></span>
                    </label>
                </div>
                @*<div class="element dark">
                    <label id="lblbw">
                        COLOR + B/W
                        <input type="checkbox" name="closed" value="closed">
                        <span class="checkmark"></span>
                    </label>
                </div>*@
                @*<div class="element">
                    <label id="lblwhite">
                    BLACK & WHITE
                    <input type="checkbox" name="closed" value="closed">
                    <span class="checkmark"></span>
                    </label>
                </div>*@
            </div>
        </div>
    }
}

I want to use where condition with foreach loop instead of if condition but unable to do that. Kindly help me with the solution as I am stuck at this point.

1 Answer 1

0

You can use where in Model as

@foreach (var item in Model.Where(c=>c.GlobalCodeCategoryValue == "115"))
    {
       
            <div class="form-group">
                @*<h6 >PICTURE FORMAT:</h6>*@
                <h6>@item.GlobalCodeCategoryName</h6>
                <div class="checkboxs round">
                    <div class="element">
                        <label id="lblcolor">
                        @*COLOR*@
                        @item.GlobalCodeName
                        <input type="checkbox" name="closed" value="closed">
                        <span class="checkmark"></span>
                        </label>
                    </div>
                    @*<div class="element dark">
                        <label id="lblbw">
                            COLOR + B/W
                            <input type="checkbox" name="closed" value="closed">
                            <span class="checkmark"></span>
                        </label>
                    </div>*@
                    @*<div class="element">
                        <label id="lblwhite">
                        BLACK & WHITE
                        <input type="checkbox" name="closed" value="closed">
                        <span class="checkmark"></span>
                        </label>
                    </div>*@
                </div>
            </div>
        
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.