Problem with DropDownList Box....

Onensehex

New Member
hi,<BR>I have declared DropDownList box as follows ::<BR><asp:DropDownList id=DropDownList1 Runat=server>asp:DropDownList><BR><BR>Now i am accessing a table(CountryNames) which is having 2 fields(CountryNames and CountryCodes).<BR><BR>Mycode::<BR><BR>strConnectionString="SERVER=myserver;UID=sa;PWD=password;APP=Microsoft (R) Developer Studio;DATABASE=temp"<BR><BR>myConnection = New SQLConnection(strConnectionString)<BR><BR>myCommand = New SQLDataSetCommand("Select * from CountryNames", myConnection)<BR><BR>ds = New DataSet<BR><BR>myCommand.FillDataSet(ds,"CountryNames")<BR>test1 = DS.Tables(0).Rows.All<BR>Dim values as ArrayList= new ArrayList()<BR>For Each item In test1<BR> values.Add(trim(item.ItemArray.GetValue(0)))<BR>Next<BR><BR>DropDownList1.DataSource = values<BR>DropDownList1.DataBind<BR><BR>I am populating the DropDownList box with Country names..so far it is working fine but my problem is i want to set the value to my second database field(Country codes) instead of Country Names with which i am Populating the list box..<BR><BR>Example::When i am looking the source code from browser its looking like this<BR> <option value=http://aspmessageboard.com/archive/index.php/"United States Of America">United States Of America</option><BR>but i want like this<BR><BR><option value="usa">United States Of America</option><BR>where "usa" is the other database feild..<BR><BR>Can any one of u help me out..please be clear in ur explanation..<BR>Thanx in Advance...<BR><BR><BR>This has the answer<BR>http://plusasp.com/plusdb/selectlist2.aspxHi Rob<BR> Than Q very much.It was of Great Help.<BR>Regards<BR>ksn
 
Top