Pergunta

columns.Bound(e => e.CreateDate).ClientTemplate("# if (CreateDate != null){#"
                                                          + @Html.Action("ChangeDate", "Home", new {date = "#= CreateDate #"}) +
                                                          "#}  else if ((CreateDate) == null)" +
                                                          "{#-#}#");

The ChangeDate action add year to date, but I got the following error:

The parameters dictionary contains a null entry for parameter 'date' of non-nullable type 'System.DateTime' for method 'System.String ChangeDate(System.DateTime)'

as error says the date value is null .

Foi útil?

Solução

If CreateDate can be null, you need to check for data.CreateDate instead.

columns.Bound(e => e.CreateDate).ClientTemplate("# if (data.CreateDate != null){#"
                                                      + @Html.Action("ChangeDate", "Home", new {date = "#= CreateDate #"}) +
                                                      "#}  else if ((data.CreateDate) == null)" +
                                                      "{#-#}#");
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top