DropDpwnList How to add some information

  • Thread starter Thread starter James
  • Start date Start date
J

James

Hello all
I have an string (array) that contains the following information (as a
sample)
AFAfghanistan
ZASouth Africa
AXAland Islands
ALAlbania
DZAlgeria
etc...
Two first characters are the ISO code of each country the array (string) is
called Countries
How can I add this information in my DropDownList in order to have the
following data:
In DataTextField:
Aghanistan
Suth Africa
Aland Islands
Albania
Algeria
In DataValueField
AF
ZA
AX
AL
DZ

Thanks a lot for your help
J
 
foreach (string MyStr in StringArray)
{
DropDownList1.Items.Add(new ListItem( MyStr.Substring(2) ,
MyStr.Substring(0,2) ));
}

Kenan
 
Back
Top