input is not pulling right bank value

Asked

Viewed 30 times

0

I need some help.

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

inserir a descrição da imagem aqui

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()?

  • Without the Tostring error and I can’t visualize the date

  • Place the breakpoint on this line of your cshtml -> CTRL+ALT+I to open the windows Window Window -> type your Model.Datarandomization.

  • breakpoint does not work on this date line

  • 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.

  • The Datarandomization variable comes from this model @model Basics.domain.Entities.ViewModel.Details within this model are the public Datetime variable? Datarandomization { get; set; }

  • @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

Show 2 more comments

1 answer

0

I got it handled, guys. 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>
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.