2012-12-10 57 views
1

我試圖根據example here將一個動作鏈接到一個網格單元:如何使用劍道網格列模板

columns.Template(@<text> 
    @Html.ActionLink("Edit", "Home", new { id = p.ProductID }) 
</text>); 

,但沒有成功。
它不是由於樣本中的錯誤而編譯的。我試圖取代:

columns.Template(p => @<text> 
    @Html.ActionLink("LinkTitle", "Edit", "Home", new { id = p.ProductID }) 
</text>); 

,並得到:

CS0201:只有分配,調用,遞增,遞減,在等待着,新 對象表達式可以作爲一份聲明中

然後我嘗試:

columns.Template(p => { 
    Html.ActionLink("LinkTitle", "Edit", "Home", new 
    { 
     id = p.ProductID 
    }); 
}); 

,並得到:

System.NotSupportedException

所以我在哪裏可以找到使用柱模板,劍道UI電網的穩定和完整的例子嗎?

+0

你試過了嗎? '.columns(@ @ Html.ActionLink(「Edit」,「Home」,new {id = @ item.ProductID}) );' –

回答

4

您需要在剃刀模板代表中使用item。它是隱含的變量名稱。將您的代碼更改爲:

columns.Template(@<text> 
    @Html.ActionLink("Edit", "Home", new { id = item.ProductID }) 
</text>); 

您鏈接到的幫助主題錯誤,並且很快就會解決。

+2

我應該把我的評論作爲答案;)。 –