aw04
aw04

Reputation: 11177

Html.DisplayFor with boolean value

Why does @Html.DisplayFor() with a boolean value display either a disabled checkbox or disabled select (depending on nullable or not) insead of true/false/nothing?

With a string, for instance, I don't get a disabled textbox.. I get the value. Why the difference?

Upvotes: 1

Views: 7410

Answers (1)

ken2k
ken2k

Reputation: 48985

Most probably, because a checkbox doesn't need to be culture-dependent: you don't have to translate true/false/nothing in every possible language. So it's much more easy for the library authors to maintain...etc.

That being said, you can of course override this default behavior. See for example Using Razor, how do I make all "bool?" properties appear as Yes/No/Not Set on details pages?

Upvotes: 1

Related Questions