input is not pulling certain value from the bank

0

I need some help.

On my system, I have an input that brings up a date from the database.

Asyoucanseeinthepictureabove,thereporteddateis06/09/201700:00,buttheactualdateofthisfieldis05/09/201722:03.

Theformatthatisinmydatabaseisthus2017-09-0522:03:03.757andjustbelowismyinputthatpullsthisdate.

<inputtype="text" class="form-control" style="text-align: center;" value="@(Model.DataRandomizacao?.ToString("dd/MM/yyyy HH:mm") ?? "Não randomizado")" disabled>

Can anyone help me?

I was able to resolve it this way.

 @{ DateTime RandomizacaoData = Convert.ToDateTime(ViewBag.Randomizacao.RandomizacaoData); }
                                    <input type="text" class="form-control" style="margin-left:0; text-align: center;" value="@RandomizacaoData.ToString("dd/MM/yyyy HH:mm")" disabled>

I just need that if there is no date it will appear "Not Randomized" as the old example.

    
asked by anonymous 01.02.2018 / 18:18

1 answer

0

I have managed to resolve personnel. Thanks to those who helped.

@if (Model.DataRandomizacao == null)
{
    <span class="input-group-addon" style="background-color:#569CD0; color:#ffffff">Data da randomização:</span>
    <input type="text" class="form-control" style="margin-left:0; text-align: center;" value="Não Randomizado" disabled>
}
else
{
    <span class="input-group-addon" style="background-color:#569CD0; color:#ffffff">Data da randomização:</span>
    DateTime RandomizacaoData = Convert.ToDateTime(ViewBag.Randomizacao.RandomizacaoData);
    <input type="text" class="form-control" style="margin-left:0; text-align: center;" value="@RandomizacaoData.ToString("dd/MM/yyyy HH:mm")" disabled>
}
    
01.02.2018 / 19:30