Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如果字典是我的数据源的一个属性,我可以使用一个特定的字典键作为DataTextField吗?_C#_Dictionary_Telerik_Rad Controls_Datatextfield - Fatal编程技术网

C# 如果字典是我的数据源的一个属性,我可以使用一个特定的字典键作为DataTextField吗?

C# 如果字典是我的数据源的一个属性,我可以使用一个特定的字典键作为DataTextField吗?,c#,dictionary,telerik,rad-controls,datatextfield,C#,Dictionary,Telerik,Rad Controls,Datatextfield,粗略类架构: public class Entity { public Guid ID; public Dictionary<String, object> Attributes; } 我想在组合框中显示键为listname的属性值作为DataTextField,但我不知道如何执行此操作。我已经在这里进行了检查,在组合框中使用字典的所有内容都涉及使用字典作为数据源。我认为这是可能的,因为它在ItemTemplate中工作,我可以使用Attributes[listna

粗略类架构:

public class Entity
{
    public Guid ID;
    public Dictionary<String, object> Attributes;
}
我想在组合框中显示键为
listname
的属性值作为DataTextField,但我不知道如何执行此操作。我已经在这里进行了检查,在组合框中使用字典的所有内容都涉及使用字典作为数据源。我认为这是可能的,因为它在ItemTemplate中工作,我可以使用
Attributes[listname]
使它在DataField属性的RadGrid中工作,但当我尝试该构造时,它不起作用


我怎样才能让它工作

当你说“我尝试那个构造,它不工作”,它怎么不工作?它是否抛出任何错误,或者只是显示空白/错误的数据?它表示它无法在该实体上找到属性[listname],或者沿着这些行的其他内容。但我在调试过程中检查了对象,它就在那里。我只需要弄清楚如何访问它。我试过使用单引号、转义双引号和无引号。他们都失败了。我尝试使用Eval(Attributes[listname]),它试图获得一个名为Attributes的类。
<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>