if else statement in Razor is not functioning

前端 未结 4 911
轻奢々
轻奢々 2021-02-05 05:01

I am using an if else in Razor view to check for null value like this:

 @foreach (var item in Model)
    {
        
                  


        
4条回答
  •  面向向阳花
    2021-02-05 05:14

    That's because you are using the Display() method incorrectly. The overload you are using is Display(HtmlHelper, String). If you are looking for "--" to be the text, you should use something like:

    @Html.Label("--");
    

提交回复
热议问题