0

Is there syntax to create a condition in the 'foreach' loop used in the view page?

@foreach (var item in Model.Where(item.Status != "C") {
<tr>
    <td>
        @Html.DisplayFor(modelItem => item.TableName)
    </td>
    .
    .
    .

The syntax for this foreach is incorrect, does anyone have an idea what it should be? (The rest of the table is truncated)

2
  • Can you clarify "doesn't work" - other than missing </tr> and } at the end of it.... I'm not sure what's wrong? Commented Jan 16, 2013 at 21:04
  • edited - per your comment Commented Jan 16, 2013 at 21:09

2 Answers 2

2
@foreach (var item in Model.Items.Where(i => i.Status != "C") {
<tr>
    <td>
        @Html.DisplayFor(modelItem => item.TableName)
    </td>
Sign up to request clarification or add additional context in comments.

Comments

1

You're missing a parenthesis on the end of the foreach line:

@foreach (var item in Model.Where(item.Status != "C")) {

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.