none
Aparecer data sem hora MVC RRS feed

  • Question

  • Pessoal sou novo com MVC estou fazendo um sisteminha em casa para aprender estou com problema na tela de alteração não estou conseguindo converter o campo datetime do sql para aparecer somente date, estou usando o MVC 5.

    Minha view

                <div class="row">
                    <div class="form-group col-md-6">
                        @Html.LabelFor(model => model.DataNascimento)
                        @Html.EditorFor(model => model.DataNascimento, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(model => model.DataNascimento, "", new { @class = "text-danger" })
                    </div>
                    <div class="form-group col-md-6">
                        @Html.LabelFor(model => model.DataAdmissao)
                        @Html.EditorFor(model => model.DataAdmissao, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(model => model.DataAdmissao, "", new { @class = "text-danger" })
                    </div>
                </div>
    FuncionarioAtributos
    using System.ComponentModel.DataAnnotations;
    
    
    namespace Capitulo06_Laboratorio.Models
    {
        [MetadataType(typeof(FuncionarioAtributos))]
        public partial class Funcionario { }
    
        public class FuncionarioAtributos
        {
            [Required]
            [Display(Name = "Telefone")]
            public string TelefoneResidencial { get; set; }
    
            [Display(Name = "País")]
            public string Pais { get; set; }
    
            [Display(Name = "Data de Nascimento")]
            [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
            public Nullable<System.DateTime> DataNascimento { get; set; }
    
            [Display(Name = "Data de Admissão")]
            [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}",ApplyFormatInEditMode = true)]
            public Nullable<System.DateTime> DataAdmissao { get; set; }
    
            [DataType(DataType.MultilineText)]
            public string Notas { get; set; }
        }
    }

    • Moved by CoolDadTx Wednesday, February 22, 2017 3:11 PM Wrong forums
    Tuesday, February 21, 2017 9:46 PM

Answers

  • Hi CLAUDIO,

    MVC topic is discussed in ASP.Net forum.

    https://forums.asp.net/


    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    • Marked as answer by CLAUDIO JOSE Wednesday, February 22, 2017 4:25 PM
    Wednesday, February 22, 2017 11:45 AM

All replies

  • Hi CLAUDIO JOSE,

    Thank you for posting here.

    According to your question is more related to MVC, you could post a new thread in MVC forum for suitable support.

    The Visual C# discuss and ask the C# programming language, IDE, libraries, samples and tools.

    If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution.

    Thanks for your understanding and cooperation.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 22, 2017 5:54 AM
  • Hello Wendy

    Sorry I posted wrong I'm posting in C # programming language, thanks
    Wednesday, February 22, 2017 11:26 AM
  • Hi CLAUDIO,

    MVC topic is discussed in ASP.Net forum.

    https://forums.asp.net/


    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    • Marked as answer by CLAUDIO JOSE Wednesday, February 22, 2017 4:25 PM
    Wednesday, February 22, 2017 11:45 AM