我想圖像添加到數據網格列中,我使用這個Telerik的網格,但我得到以下錯誤,其對51號線:添加到Telerik的數據網格列的圖像
編譯器錯誤信息: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>
是否有您使用的是客戶端和服務器模板理由嗎?我認爲這個演示程序幾乎就是你想要的,只需使用你的刪除鏡像就可以了:http://demos.telerik.com/aspnet-mvc/grid/templatesserverside – MisterIsaak
@Jisaak我嘗試了你提供的演示方式,仍然可以得到關於無效表達術語')'的相同錯誤。我上面更新了我的代碼 – user793468