我有一个三个嵌套中继器的结构来呈现标签,然后在这些标签下按标题分组。我一直在标准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