Question

I have this line but not sure about the + string part. It is not correct as it is now:

 <p>
    <%: Html.ActionLink("TUK-JS-KPI-WE-" + ((DateTime)Eval(ViewBag.jobSortedReportDate)).ToString("yyyy-MM-dd"), "TradeUKKPIReportInstructions", "Report", new { @date = ViewBag.jobSortedReportDate }, 0)%>    
 </p>

How do I add text to value?

Était-ce utile?

La solution

If jobSortedReportDate contains string value you should cast it to a string, just like like that:

<%: Html.ActionLink("TUK-JS-KPI-WE-" + (string)ViewBag.jobSortedReportDate, "TradeUKKPIReportInstructions", "Report", new { @date = ViewBag.jobSortedReportDate }, 0)%> 

Autres conseils

You can also try this

<%: Html.ActionLink(String.Format("TUK-JS-KPI-WE-{0}", (DateTime) ViewBag.jobSortedReportDate), "TradeUKKPIReportInstructions", "Report", new { @date = ViewBag.jobSortedReportDate }, 0)%>

Here is alternative

<a href="@Url.Action("TradeUKKPIReportInstructions", new {Controller = "Report", @date = ViewBag.jobSortedReportDate })">@String.Format("TUK-JS-KPI-WE-{0}", ViewBag.jobSortedReportDate )</a>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top