I am developing MVC application with Kedno grid. I have a model Item with properties:
public bool IsPaid { get; set; }
public Nullable<DateTime> PaymentDate { get; set; }
In Kedno grid in the View:
columns.Bound(c => c.PaymentDate).Format("{0:dd-MMM-yyyy}");
When I am editing in the grid and set IsPaid to false to logic has to be setting PaymentDate to null.
For example I have an Item with PaymentDate 22-Sep-2016 and IsPaid to true
.
After editing in Kendo grid this Item setting IsPaid to false, and when I click Save Changes, it is invoked the method Update in the controller:
public ActionResult Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<ItemViewModel> items)
{
if (ModelState.IsValid)
{
//
}
}
But the ModelState is not valid: "The value '9/22/2016 12:00:00 AM' is not valid for...".
If the PaymentDate is 01-Sep-2016, the ModelState is valid.
Also, I followed the steps in the Globalization section.
In web.config:
<globalization uiCulture="bg-BG" culture="bg-BG"></globalization>
In Controller:
protected override void Initialize(RequestContext requestContext)
{
Thread.CurrentThread.CurrentCulture =
Thread.CurrentThread.CurrentUICulture =
new CultureInfo(requestContext.HttpContext.Request.UserLanguages[0]);
base.Initialize(requestContext);
}
In View:
@{
var culture = System.Globalization.CultureInfo.CurrentCulture.ToString();
}
<script src="@Url.Content("~/scripts/cultures/kendo.culture." + culture + ".min.js")"></script>
<script>
kendo.culture("@culture");
</script>
Any suggestions?
Thanks a lot!