0

我有这一行,但不确定 + 字符串部分。不像现在这样正确:

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

如何将文本添加到值?

4

2 回答 2

3

如果jobSortedReportDate包含字符串值,您应该将其转换为字符串,就像这样:

<%: Html.ActionLink("TUK-JS-KPI-WE-" + (string)ViewBag.jobSortedReportDate, "TradeUKKPIReportInstructions", "Report", new { @date = ViewBag.jobSortedReportDate }, 0)%> 
于 2012-08-21T07:21:24.050 回答
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>
于 2012-08-21T07:30:30.987 回答