C# 如何使用foreach创建列表并按字母顺序将项目添加到radiobuttonlist

C# 如何使用foreach创建列表并按字母顺序将项目添加到radiobuttonlist,c#,umbraco,C#,Umbraco,我从Umbraco和works 100%获得文本和键值,但这样我无法对我获得的列表排序。该站点将使用不同的语言,我需要在radiobuttonlist上按值(即按语言)而不是按Umbraco中的键订购项目。可以吗 foreach (umbraco.cms.businesslogic.Dictionary.DictionaryItem d2 in d1.Children) { translation = ""; translation = new umbraco.cms.busin

我从Umbraco和works 100%获得文本和键值,但这样我无法对我获得的列表排序。该站点将使用不同的语言,我需要在
radiobuttonlist
上按值(即按语言)而不是按Umbraco中的键订购项目。

可以吗

foreach (umbraco.cms.businesslogic.Dictionary.DictionaryItem d2 in d1.Children)
{
    translation = "";
    translation = new umbraco.cms.businesslogic.Dictionary.DictionaryItem(d2.key).Value(lang);

    ListItem list; //start a list

    list = new ListItem(translation, d2.key); //save each item on it

    rbl_items.Items.Add(list); //add them to my radiobuttonlist
}

您可以将每个元素添加到
foreach
中的第一个元素中。然后,您可以将
RadioButtonlist
绑定到此SortedList,如中所示


谢谢你,先生,我不能要求一个更好更快的答案!你就是那个人!
SortedList list= new SortedList();

foreach (umbraco.cms.businesslogic.Dictionary.DictionaryItem d2 in d1.Children)
{
    translation = "";
    translation = new umbraco.cms.businesslogic.Dictionary.DictionaryItem(d2.key).Value(lang);

    list.Add(translation, d2.key);
}

//bind to RadioButtonList 
RadioButtonList1.DataSource = list;
RadioButtonList1.DataValueField = "Key";
RadioButtonList1.DataTextField="Value";
RadioButtonList1.DataBind();