1

I am trying to format the output of a query in a WebMatrix 2 CSHTML file. This is the code I am using:

@foreach(var row in db.Query(selectQueryString))
{
   @row.Firstname; + " " + @row.lastname; + " " + @row.Entry;
}

I am getting this error:

"CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement"

1 Answer 1

1

The first issue is that the semicolons could be confusing to Razor, and they are only confusing matters. So change the line in the brackets to

<text>@row.Firstname @row.lastname @row.Entry</text>

And see if that works. The < text > tags tells Razor to output this directly as HTML and not use it as code. You don't need the + " " because once you're putting out HTML, the spaces come automatically.

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.