5
I have an object Carro
and I have a whole-type, annulable property called AnoInspecao
. When creating, I can create a car object with the year of null inspection (without typing anything) and persist in the bank normally.
var carro = new Carro()
{
carro.AnoInspecao = null;
carro.Nome = "meuCarro"
}
When it’s time to edit (View), I use the following code:
@Html.TexboxFor(model => model.AnoInspecao)
But it doesn’t work, because the Textbox
does not accept null, thus generating a Exception
.
How can I treat that?
It only creates an exception when the
AnoInspecao
is null, certain?– Jéf Bueno
Exactly @jbueno
– Igor Macedo