Wrox Programmer Forums
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 23rd, 2005, 02:03 PM
Registered User
Join Date: Sep 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?
Old November 23rd, 2005, 03:06 PM
Friend of Wrox
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts

Check this link:

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


Old February 22nd, 2010, 04:31 AM
Registered User
Join Date: Dec 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

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
Old June 21st, 2010, 10:05 PM
Authorized User
Join Date: Apr 2010
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts

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?
Old July 31st, 2010, 04:29 AM
Registered User
Join Date: Jul 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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;[email protected];");

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/
Old November 30th, 2013, 12:15 PM
Registered User
Join Date: Nov 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
populate a drop list fro a data table greenbriar ADO.NET 2 July 22nd, 2008 10:18 PM
populate drop down list with a function code3hree Javascript 1 May 28th, 2005 11:44 AM
populating a drop down with a file list cjcd ASP.NET 1.0 and 1.1 Professional 2 April 18th, 2004 10:37 AM
populating a drop down with a file list cjcd BOOK: Beginning ASP.NET 1.0 1 April 17th, 2004 02:53 AM

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