粗略的类模式:
public class Entity
{
public Guid ID;
public Dictionary<String, object> Attributes;
}
属性具有以下键:listname (string), membercount(integer), type (boolean)
.
我有一个 Telerik RadComboBox,它通过代码隐藏到列表中进行数据绑定,并且有一个 ItemTemplate:
<telerik:RadComboBox runat="server" ID="CboLists" DataValueField="Id">
<ItemTemplate>
<table>
<tr>
<td>
<b><%# DataBinder.Eval(Container.DataItem, "Attributes['listname']") %></b> (<%# ViewHelper.GetBooleanValue("list", "type",(bool)((Entity)Container.DataItem).Attributes["type"]) %>)
</td>
</tr>
<tr>
<td>
<%# DataBinder.Eval(Container.DataItem, "Attributes['membercount']") %> Leden
</td>
</tr>
</table>
</ItemTemplate>
</telerik:RadComboBox>
我想用listname
组合框中的键将属性的值显示为 DataTextField,但我不知道如何执行此操作。我已经检查了here,我能找到的在组合框中使用字典的所有内容都涉及使用字典作为数据源。我认为这是可能的,因为它在 ItemTemplate 中工作,并且我可以使用 RadGrid 在 DataField 属性上工作Attributes[listname]
,但是当我尝试该构造时,它不起作用。
我怎样才能让它工作?