Greetings,
I'm currently in the process of creating a grid to display comments on a product. There is some data migration that has forced two DateTime fields to be required Null and the grid seems to be throwing fits about it. I get the following error when it happens:
Model
Any help would be appreciated. Thank you.
Kindest Regards,
Chad Johnson
I'm currently in the process of creating a grid to display comments on a product. There is some data migration that has forced two DateTime fields to be required Null and the grid seems to be throwing fits about it. I get the following error when it happens:
The model item passed into the dictionary is null, but this dictionary requires a non-null model item of type 'System.DateTime'.
I have been researching the topic and had little success on solving the problem. Here is a sample of my code thus far.
View
@(Html.Telerik().Grid<ProductModel.ProductCommentsModel>() .Name("productcomments-grid") .DataKeys(keys => { keys.Add(x => x.Id); }) .DataBinding(dataBinding => { dataBinding.Ajax() .Select("ProductCommentsList", "Product", new { productId = Model.Id }) .Update("ProductCommentUpdate", "Product") .Delete("ProductCommentDelete", "Product"); }) .Columns(columns => { columns.Bound(x => x.Id) .Hidden(true); columns.Bound(x => x.ProductId) .Hidden(true); columns.Bound(x => x.CustomerId) .Hidden(true); columns.Bound(x => x.CustomerName) .Width(200) .ReadOnly(true); columns.Bound(x => x.CreatedDate) .Width(100) .ReadOnly(true); columns.Bound(x => x.LastModifiedDate) .Width(100) .ReadOnly(true); columns.Bound(x => x.Comment); columns.Command(commands => { commands.Edit().ButtonType(GridButtonType.Text); commands.Delete().ButtonType(GridButtonType.Text); }); }) .Editable(edit => edit.Mode(GridEditMode.PopUp)) .EnableCustomBinding(true))Model
public partial class ProductCommentsModel : BaseNopEntityModel { public int ProductId { get; set; } public int CustomerId { get; set; } public string CustomerName { get; set; } [Required(AllowEmptyStrings=true)] [DisplayFormat(NullDisplayText = "", DataFormatString = "0:MM/dd/yyyy")] public DateTime? CreatedDate { get; set; } [Required(AllowEmptyStrings = true)] [DisplayFormat(NullDisplayText = "", DataFormatString = "0:MM/dd/yyyy")] public DateTime? LastModifiedDate { get; set; } public DateTime? SentForRepair { get; set; } public string Comment { get; set; } }Any help would be appreciated. Thank you.
Kindest Regards,
Chad Johnson