sowjanya

sowjanya

  • NA
  • 2
  • 0

Drop down list

Mar 20 2010 2:26 AM
Hi i was given some coding in my institute which I am unable to understand.It is regarding creating user defined drop down list of languages spoken that are supported by os...can you please explain me the coding of it clearly....

public class CultureDropdown : DropDownList
    {

        protected override void OnLoad(EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                SortedList lst = getAvailableCultures();
                DataSource = getAvailableCultures();
                DataValueField = "Value";
                DataTextField = "Key";
                DataBind();

            }
        }

        private SortedList getAvailableCultures()
        {
            SortedList results = new SortedList();

            string[] languages = ((string)((IDictionary)
WebConfigurationManager.GetSection("supportedLanguages"))["languages"]).Split(',');
            foreach (string language in languages)
            {
                foreach (CultureInfo specific in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
                {
                    if (specific.TwoLetterISOLanguageName == language)
                    {
                        results.Add(specific.DisplayName, specific.Name);

                    }
                }
            }

            return results;
        }
 


Thanks in advance

Answers (1)