Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am working on mvc3 with entity framework(.edmx), in this project i am using juery datepicker for select a date when i select date format (dd/mm/yyyy) then data not insert into database because
ModelState.Isvalid become false how can i resolve it.

please help

thanks in advance
Posted

Dear Member 10371658356,

Please, do the following changes:


1. Model Change:

SQL
[Required(ErrorMessage="Scheme End Date Required")]
[Display(Name="End Date")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd-MMM-yyyy}", ApplyFormatInEditMode = true)]
public DateTime EndDate { get; set; }



2. Change Web Config :

XML
<system.web>
    <globalization  uiCulture ="en" culture ="en-GB"/>
  </system.web>



Try this.

Thanks,
Manoj Kalla
 
Share this answer
 
Try the DisplayFormat attribute like below
C#
public class MyViewModel
{
    [DisplayName("date of birth")]
    [DataType(DataType.Date)]
    [DisplayFormat(DataFormatString = "{dd/mm/yyyy}", ApplyFormatInEditMode = true)]
    public DateTime? Birth { get; set; }
}


Hope this helps
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900