1
我有這樣的:無法做鑄造
<%foreach (var item in (List<MyClass>)ViewData["something"]) {%>
和它拋出異常:無法轉換類型 '<> f__AnonymousType0 1[System.Collections.Generic.List
1 [MyClass的]]' 爲類型「的對象System.Collections.Generic.List `1 [MyClass的]」。
ViewData [「something」]包含一個具有四個元素的myClass對象。如何解決這個問題?
var xx= (from x in be.x
select x).ToList();
ViewData["something"] = new { xx };
你在你的控制器設置計算機[ 「東西」]來? – 2012-03-13 11:46:59
@TrevorPilley我編輯了這個問題。請參見。 – 2012-03-13 11:51:23