Users Pricing

forum

How to apply Where Clause condition in foreach loop in MVC razor view?

Anonymous User 2535 18 Dec 2017

Hi,

Below is my code,

 @foreach (var item in Model)

                        {
                            if (item.Type == "Technical") {
  <a style="margin-bottom:30px" class="text-white contentFontSize" href="@Url.Action("Index", "Question", new { FilterBy = "technology", FilterText = item.Technology, Type = "Technical" })">
                                 <span class="float-left col-md-2" style="padding: 20px; text-transform: uppercase">@item.Technology &nbsp;&nbsp; @item.TotalCount </span>
                            </a>
   }
                        }

I want to write my conditional statement in foreach loop. It is possible to write a conditional statement with foreach loop. If yes please give me some idea.


I am a content writter !


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md