This is a migrated thread and some comments may be shown as answers.

DatePicker and DateTimePicker both throw exception: Value cannot be null. Parameter name: key

1 Answer 130 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Eddie
Top achievements
Rank 1
Eddie asked on 12 Sep 2013, 09:55 PM
Hi,

I have a datepicker on my cshtml view.  I'm creating it with the following line (which I'm using elsewhere successfully):
@Html.Kendo().DateTimePicker().HtmlAttributes(new { @id = "fltBeginDate" }).Value(DateTime.Now).Format("MM/dd/yyyy")
When the view tries to load, I get the following error:
Value cannot be null.
Parameter name: key

StackTrace:
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at System.Web.Mvc.ModelStateDictionary.TryGetValue(String key, ModelState& value)
   at Kendo.Mvc.UI.InputComponentExtensions.GetAttemptedValue[T](IInputComponent`1 instance)
   at Kendo.Mvc.UI.Html.DatePickerHtmlBuilderBase.Build()
   at Kendo.Mvc.UI.DateTimePicker.WriteHtml(HtmlTextWriter writer)
   at Kendo.Mvc.UI.WidgetBase.ToHtmlString()
   at Kendo.Mvc.UI.Fluent.WidgetBuilderBase`2.ToHtmlString()
   at System.Web.HttpUtility.HtmlEncode(Object value)
   at System.Web.WebPages.WebPageBase.Write(Object value)
   at ASP._Page_Views_PlantDeclaration_Index_cshtml.Execute()

Any help is appreciated!

Thanks,

Eddie

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 13 Sep 2013, 09:09 AM
Hello Eddie,

 
I noticed that the Name method is missed in the DateTimePicker declaration. Please note that the widget requires Name to work correctly:

@Html.Kendo().DateTimePicker().Name("fltBeginDate").Value(DateTime.Now).Format("MM/dd/yyyy")

Regards,
Georgi Krustev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Date/Time Pickers
Asked by
Eddie
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or