Note that there are some explanatory texts on larger screens.

plurals
  1. POany better way of Sorting my dropdownlist
    primarykey
    data
    text
    <p>After I retrieve the country names in English,I convert the country names to localized versions,I need to sort those names again so I used <em>SortDropDownList</em>. Here after I sort my dropdownlist Items,I am loosing the <em>PrivacyOption</em> Attribute I set. Can some one suggest me some solution so that I can sort my dropdownlist at the same time I want to retain the privacy option attribute I am using asp.net4.0 along with C# as codebehind</p> <pre><code>int iCount = 1; //fetch country names in English List&lt;CountryInfo&gt; countryInfo = ReturnAllCountriesInfo(); foreach (CountryInfo c in countryInfo) { if (!string.IsNullOrEmpty(Convert.ToString( LocalizationUtility.GetResourceString(c.ResourceKeyName)))) { ListItem l = new ListItem(); l.Text = Convert.ToString( LocalizationUtility.GetResourceString(c.ResourceKeyName)); l.Value = Convert.ToString( LocalizationUtility.GetResourceString(c.ResourceKeyName)); //True /False* l.Attributes.Add("PrivacyOption", *Convert.ToString(c.PrivacyOption)); drpCountryRegion.Items.Insert(iCount, l); iCount++; } //sorts the dropdownlist loaded with country names localized language SortDropDownList(ref this.drpCountryRegion); } </code></pre> <p>And the code to sort dropdownlist items</p> <pre><code>private void SortDropDownList(ref DropDownList objDDL) { ArrayList textList = new ArrayList(); ArrayList valueList = new ArrayList(); foreach (ListItem li in objDDL.Items) { textList.Add(li.Text); } textList.Sort(); foreach (object item in textList) { string value = objDDL.Items.FindByText(item.ToString()).Value; valueList.Add(value); } objDDL.Items.Clear(); for (int i = 0; i &lt; textList.Count; i++) { ListItem objItem = new ListItem(textList[i].ToString(), valueList[i].ToString()); objDDL.Items.Add(objItem); } } </code></pre> <p>After I retrieve the country names in English,I convert the country names to localized versions,I need to sort those names again so I used SortDropDownList. Here after I sort my dropdownlist Items,I am loosing the PrivacyOption Attribute I set. Can some one suggest me some solution so that I can sort my dropdownlist at the same time I want to retain the privacy option attribute</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload