0

我想将图像添加到数据网格列,为此我正在使用 Telerik 网格,但是我收到以下错误,它位于第 51 行:

编译器错误消息:CS1525:无效的表达式术语 ')'

源错误:

Line 49:     column.Bound(o => o.HoursWorked).Title("Hours");
Line 50:     column.Template(o =>
Line 51:     {%>
Line 52:     <img src="/Content/img/delete.png" alt="Delete" title="Delete"/>
Line 53:     <%

这是我尝试将图像添加到列的方式:

<div>
<%=Html.CustomGridFor("Hours", "WorkHours", "HoursWorked", GridOptions.EnableSelecting, Model).Columns(column =>
   {
     column.Bound(o => o.DateWorked).Title("Date").Width("65px");
     column.Bound(o => o.Description).Title("Description").Width("120px");
     column.Bound(o => o.HoursWorked).Title("Hours");
     column.Template(o =>
     {%>
     <img src="/Content/img/delete.png" alt="Delete" title="Delete" onclick="javascript:deleteHours();" />
     <%
     }).Title("").ClientTemplate(
     "<img src=\"/Content/img/delete.png\" alt=\"Delete\" title=\"Delete\"/>"
     ).Width(15);
     }).HtmlAttributes(new { style = "width: 270px;" });
     %>
</div>

也试过这个:

<div>
<%=Html.CustomGridFor("Hours", "WorkHours", "HoursWorked", GridOptions.EnableSelecting, Model).Columns(column =>
   {
     column.Bound(o => o.DateWorked).Title("Date").Width("65px");
     column.Bound(o => o.Description).Title("Description").Width("120px");
     column.Bound(o => o.HoursWorked).Title("Hours");

        column.Template(o =>
        {
        %>
            <img 
                alt="Delete" 
                src="/Content/img/delete.png" 
              />
        <%
        });

</div>
4

1 回答 1

1

尝试使用这个:

<div>
<%=Html.CustomGridFor("Hours", "WorkHours", "HoursWorked", GridOptions.EnableSelecting, Model).Columns(column =>
        {
           column.Bound(o => o.DateWorked).Title("Date").Width("65px");
           column.Bound(o => o.Description).Title("Description").Width("120px");
           column.Bound(o => o.HoursWorked).Title("Hours");
           column.Template(o => string.Empty).Title("")
                 .ClientTemplate(
                      "<img src=\"/Content/img/delete.png\" alt=\"Delete\" title=\"Delete\"/>")
                 .Width(15);
        }).HtmlAttributes(new { style = "width: 270px;" });
%>
</div>
于 2012-10-17T10:02:40.257 回答