我有这条线但不确定+字符串部分。它现在不正确:
<p>
<%: Html.ActionLink("TUK-JS-KPI-WE-" + ((DateTime)Eval(ViewBag.jobSortedReportDate)).ToString("yyyy-MM-dd"), "TradeUKKPIReportInstructions", "Report", new { @date = ViewBag.jobSortedReportDate }, 0)%>
</p>
如何将文字添加到值?
答案 0 :(得分:3)
如果jobSortedReportDate
包含字符串值,则应将其强制转换为字符串,如下所示:
<%: Html.ActionLink("TUK-JS-KPI-WE-" + (string)ViewBag.jobSortedReportDate, "TradeUKKPIReportInstructions", "Report", new { @date = ViewBag.jobSortedReportDate }, 0)%>
答案 1 :(得分:0)
你也可以尝试这个
<%: Html.ActionLink(String.Format("TUK-JS-KPI-WE-{0}", (DateTime) ViewBag.jobSortedReportDate), "TradeUKKPIReportInstructions", "Report", new { @date = ViewBag.jobSortedReportDate }, 0)%>
这是替代
<a href="@Url.Action("TradeUKKPIReportInstructions", new {Controller = "Report", @date = ViewBag.jobSortedReportDate })">@String.Format("TUK-JS-KPI-WE-{0}", ViewBag.jobSortedReportDate )</a>