I want to create language selector in the site header. So for that i am trying to pick all language(/sitecore/system/Languages) from Sitecore dynamically using repeater. I am able to get language values from Sitecore but in the page i am not getting language dropdown.

My view Code :

    <div class="ddlCountry"> Select Language:
    <asp:Repeater ID="rpLang" ItemType="Sitecore.Data.Items.Item" runat="server">
            <listitem text=<%#: Item.Name %> runat="server"/>

My Back-end Code:

public partial class CountryRegionSublayout : System.Web.UI.UserControl
    protected void Page_Load(object sender, EventArgs e)
        Item lang = Sitecore.Context.Database.GetItem("/sitecore/system/Languages");

            Item[] children = lang.Children.ToArray();
            rpLang.DataSource = children;

  • Instead of using the listitem, can you please use the asp:DropDownList Sep 25, 2019 at 6:56

1 Answer 1


Ideally to display , languages in a dropdown , you should use a droplist.

<asp:DropDownList runat="server" ID="languagesDropDown" EnableViewState="False" />

To display the items in Key/Value pair in the dropdown, Modify the code below accordingly

    protected override void OnInit(EventArgs e)
        foreach (var definition in LanguageDefinitions.Definitions)
            //var cultureInfo = Language.CreateCultureInfo(definition.Name);
            var listItem = new ListItem(Language.GetDisplayName(cultureInfo), definition.Name);


Please take reference from the InstallLanguage.aspx available in /sitecore/admin folder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.