Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 23rd, 2005, 01:03 PM
Registered User
 
Join Date: Sep 2003
Location: , , .
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:
<states>
    <state>
        <state_name>Alabama</state_name>
        <abbreviation>AL</abbreviation>
    </state>
    <state>
        <state_name>Alaska</state_name>
        <abbreviation>AK</abbreviation>
    </state>
etc...
</states>

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?
Reply With Quote
  #2 (permalink)  
Old November 23rd, 2005, 02:06 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,346
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Check this link:
http://www.w3schools.com/aspnet/aspnet_xml.asp

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

Jim

Reply With Quote
  #3 (permalink)  
Old February 22nd, 2010, 03:31 AM
Registered User
 
Join Date: Dec 2008
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
__________________
http://www.connectionstringexamples.com
http://www.quangvo.com (Make my first million online)
http://www.qvis.com.au
Reply With Quote
  #4 (permalink)  
Old June 21st, 2010, 10:05 PM
Authorized User
 
Join Date: Apr 2010
Location: Seattle, WA
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
Default

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?
Reply With Quote
  #5 (permalink)  
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;

//Query
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;");

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


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

}
catch (Exception ex)
{
con.Close();
throw new Exception(ex.Message, ex);
}

More info visit :http://www.book4dotnet.com/
Reply With Quote
  #6 (permalink)  
Old November 30th, 2013, 11:15 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 12:17 AM.


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