C# 将字符串数组绑定到DropDownList?

C# 将字符串数组绑定到DropDownList?,c#,asp.net,visual-studio-2010,C#,Asp.net,Visual Studio 2010,一个我从未解决过的问题。我将用两个代码示例说明其中一个有效,另一个无效: Page_Load() { FontFamily[] oFamilyFontList = FontFamily.Families; DropDownList_Fonts.DataSource = oFamilyFontList; DropDownList_Fonts.DataBind(); string[] colorName = System.Enum.G

一个我从未解决过的问题。我将用两个代码示例说明其中一个有效,另一个无效:

Page_Load()
{
        FontFamily[] oFamilyFontList = FontFamily.Families;
        DropDownList_Fonts.DataSource = oFamilyFontList;
        DropDownList_Fonts.DataBind();

        string[] colorName = System.Enum.GetNames(typeof(KnownColor));
        DropDownList_FontColor.DataSource = colorName;
        DropDownList_FontColor.DataBind();
}

第一个DropDownList填充得很好,没有任何错误,因为AMILYFONTLIST的每个对象都有一个属性“Name”,该属性与DataText和DataValue字段绑定


第二个完全没有属性,它只是一个字符串数组。我可以在这两个字段中放入什么使其工作?

是的,您可以绑定数组,但必须删除
DataTextField
DataValueField
属性

<asp:DropDownList 
        ID="DropDownList_FontColor"
        runat="server">
</asp:DropDownList>


也许是个愚蠢的问题-但是-colorName数组中有值吗?当然有,AVD已经回答了我的问题。我真的觉得自己很愚蠢。非常感谢你的回答,它成功了。@yahyakh-里面没有什么愚蠢的东西。当显然需要帮助时,你应该毫不犹豫地寻求帮助。
<asp:DropDownList 
        ID="DropDownList_FontColor"
        runat="server">
</asp:DropDownList>