p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 1.0 and 1.1 Basics (http://p2p.wrox.com/forumdisplay.php?f=60)
-   -   Populate drop down list with XML file (http://p2p.wrox.com/showthread.php?t=35382)

rlull November 23rd, 2005 02:03 PM

Populate drop down list with XML file
I have a simple XML file for US states formatted as follows:

How do I bind to a drop down list so that the state_name is displayed but the abbreviation is the actual value of the row?

jbenson001 November 23rd, 2005 03:06 PM

Check this link:

You first have to import the XML into a dataset, then bind to the dataset.


quangvo February 22nd, 2010 04:31 AM

This is great. You can use the dataset to do it quicky this link show you how to do it nicely. http://www.itjungles.com/dropdownlis...-with-xml-in-c

krahman01 June 21st, 2010 10:05 PM

The above example is great to pull the value out from XML file, but, what happens you multiple dropdowns as opposed to a single dropdown above?

venubv July 31st, 2010 04:29 AM

Populate Values from DB to Drop Downlist
//Declare SqlCommand
SqlCommand cmd;
//Declare SqlAdapter
SqlDataAdapter da;
//Decalre Dataset
DataSet ds;

//Declare String
string strQuery;

strQuery = "Select Column_Id,Column_Desc from Test_Table";

//decalre Connection to DB
SqlConnection con = default(SqlConnection);

//Connection String to SQL 2005
con = new SqlConnection("Data Source=MYServer-PC\\SQLEXPRESS;Initial Catalog=Sample_New;User Id=sa;Password=test@123;");

cmd = new SqlCommand(strQuery, con);
da = new SqlDataAdapter(cmd);
ds = new DataSet();
if (con.State != ConnectionState.Closed)
wddltest.DataSource = ds;

wddltest.DataTextField = "Column_Desc";
wddltest.DataValueField = "Column_Id";
//wddltest.Items.Insert(0, New ListItem("All", "0"));

catch (Exception ex)
throw new Exception(ex.Message, ex);

More info visit :http://www.book4dotnet.com/

BustinJustin November 30th, 2013 12:15 PM

Any way to do this locally in the browser without a server?

All times are GMT -4. The time now is 04:21 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.