Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If condition in @Html.DisplayFor

I am trying to display different messages based on data from statusid table. Let say for example if my statusid is 1120 then i would like to display "PASS" but i am struggling with the correct syntax.

If statusid=1120 then "PASS".

Here is my code for displaying statusid:

@Html.DisplayFor(modelItem => item.statusid)

Any idea?

like image 414
sensahin Avatar asked Jan 11 '23 13:01

sensahin


1 Answers

Make an object with all the properties you need

SomeObject.statusId
SomeObject.message

@Html.DisplayFor(modelItem => item.SomeObjectInstance)

Doing it this way let's you add the code and logic outside the view, which is generally recommended.

like image 171
TGH Avatar answered Feb 13 '23 05:02

TGH