0
I need some help.
On my system, I have an input that brings back a date from the database.
As you can see in the photo above the date informed is 06/09/2017 00:00
, only that the actual date of this field is 05/09/2017 22:03
.
The format on my bench is like this 2017-09-05 22:03:03.757
and just below is my input pulling this date.
<input type="text" class="form-control" style="text-align: center;" value="@(Model.DataRandomizacao?.ToString("dd/MM/yyyy HH:mm") ?? "Não randomizado")" disabled>
someone could help me?
I managed to solve 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>
only that I need that if there is no date it appears "Non-randomized" as the old example.
What is the value of Datarandomization without Tostring()?
– Gabriel Coletta
Without the Tostring error and I can’t visualize the date
– Leonardo Macedo
Place the breakpoint on this line of your cshtml -> CTRL+ALT+I to open the windows Window Window -> type your Model.Datarandomization.
– Gabriel Coletta
breakpoint does not work on this date line
– Leonardo Macedo
Are you in debug mode? It goes in your Controller, where you have the Action that calls this View and see the Model that you return to the View.
– Gabriel Coletta
The Datarandomization variable comes from this model @model Basics.domain.Entities.ViewModel.Details within this model are the public Datetime variable? Datarandomization { get; set; }
– Leonardo Macedo
@Gabrielcoletta I managed to solve another way, only I’m with another problem, if there is a date, it appears "Not randomized" I will edit the code and show how I did
– Leonardo Macedo