2012-10-12 52 views
0

我想圖像添加到數據網格列中,我使用這個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> 
+1

是否有您使用的是客戶端和服務器模板理由嗎?我認爲這個演示程序幾乎就是你想要的,只需使用你的刪除鏡像就可以了:http://demos.telerik.com/aspnet-mvc/grid/templatesserverside – MisterIsaak

+0

@Jisaak我嘗試了你提供的演示方式,仍然可以得到關於無效表達術語')'的相同錯誤。我上面更新了我的代碼 – user793468

回答

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> 
+0

我仍然收到錯誤:編譯器錯誤消息:CS1525:無效的表達式項')'正在移除「;」從最後一行添加另一列沒有標題,但仍然看不到刪除圖像。 – user793468

+0

您能否顯示在此列中生成的客戶端中沒有標題的html? –

+0

這是我所看到的: user793468

相關問題