我有一個三個嵌套中繼器的結構來呈現標籤,然後在這些標籤下按標題分組。我一直在標準IEnumerable
類型中成功使用.NET 4.5中的強類型數據控件,但這是我第一次使用Dictionary<T1,T2>
。儘管如此,我已經看到另一Stackoverflow question使用Dictionary
作爲DataSource
成功宣佈ItemType
爲KeyValuePair<T1, T2>
。複雜ItemType失敗的強類型DataControl(Repeater)
標記:
<asp:Repeater ID="rptTabs" runat="server"
ItemType="System.Collections.Generic.KeyValuePair<System.String, System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.List<Sitecore.Data.Items.Item>>>">
<ItemTemplate>
<%# Item.Key %>
<%-- ... more repeaters under but they are commented out for now as it's the outer on that is failing --%>
</ItemTemplate>
</asp:Repeater>
代碼隱藏:
var myDatasource = new Dictionary<string, Dictionary<string, List<Item>>>();
// add some items
rptTabs.DataSource = myDatasource;
rptTabs.DataBind();
這裏的異常/堆棧跟蹤我越來越:
看起來好像頁面無法因爲它無法解決string
的ItemType問題 名稱。問題是,我在我的<%# Item.Key #%>
上收到intellisense,因此intellisense引擎可以通過字符串名稱解析該類型,但運行時不能?
注:我懷疑這是Sitecore.Data.Items.Item
類型失敗,因爲我之前在IEnumerable中使用它,意味着ItemType是Sitecore.Data.Items.Item
。
任何幫助,將不勝感激!
我真的不想寫'ItemDataBound'處理程序來簡單地通過ID找到內部控件並綁定它們的數據源。煩! – benmccallum 2013-04-23 05:33:07