Note that there are some explanatory texts on larger screens.

plurals
  1. POWebGrid: cannot convert from 'lambda expression' to 'System.Func<dynamic,object>'
    primarykey
    data
    text
    <p>I am trying to handle a case of a DateTime which might be null when rendering in a ASP.NET MVC3 WinGrid. I am getting an error when trying to set the WebGridColumn. I have one that I got working, one that isn't. The one that is working is less idea, for the html is generated within the helper function. What I cannot figure out is why the ideal one isn't working. </p> <p>Here is the one that works:</p> <pre><code>$gridSummary.Column("OngoingDate", header: "Ongoing", format: Html.DateTimeActionLink, style: "ongoingDate") public static object DateTimeActionLink(this HtmlHelper htmlHelper, dynamic item) { DateTime? linkDateTime = item.OngoingDate; if (linkDateTime != null &amp;&amp; linkDateTime.HasValue) { var x = linkDateTime.Value.ToString("MM/dd/yyyy"); return LinkExtensions.ActionLink(htmlHelper, x, "Edit", "MdsAsmtSectionQuestions", new { mdsId = item.OngoingId }, null); } return MvcHtmlString.Empty; } </code></pre> <p>here is the one that is not working:</p> <pre><code> $gridSummary.Column("AssessmentInfo", header: "Open Type | ARD", format: (item) =&gt; { return Html.DateTimeActionLink( item.AssessmentDate, "MM/dd/yyyy", x =&gt; Html.ActionLink(item.AssessmentInfo + " | " + x, "Edit", "MdsAsmtSectionQuestions", new { mdsId = item.OngoingId }, null)); }, style: "assessmentInfo") public static object DateTimeActionLink(this HtmlHelper htmlHelper, dynamic item, string format, Func&lt;string, MvcHtmlString&gt; actionLink) { Nullable&lt;DateTime&gt; linkDateTime = item; if (linkDateTime != null &amp;&amp; linkDateTime.HasValue) return actionLink(linkDateTime.Value.ToString(format)); return MvcHtmlString.Empty; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload