0

I'm not sure if this is possible in the view or if I would somehow have to check for it in the controller but I have some values that are null and I'm trying to fill up a table but I would like a placeholder such as N/A to show up if there's no values.

In my controller I'm just return the model data of a basic linq query.

var model = from u in db.Users where u.Username == "Bob" select u; 

In my view I'm just simply displaying the data in a table

<table class='table table-striped table-bordered table-responsive'> <tbody> <tr> <td>@Html.DisplayFor(model => model.CallNo)</td> </tr> </tbody> </table> 

1 Answer 1

1

you can do something like this in your model:

[DisplayFormat(NullDisplayText = "PLACEHOLDER_VALUE")] public string CallNo { get; set; } 

Doing this you can just use

@Html.DisplayFor(model => model.CallNo)

as usual.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.