Wrox Programmer Forums
| 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 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
  #1 (permalink)  
Old November 23rd, 2005, 02: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?
  #2 (permalink)  
Old November 23rd, 2005, 03:06 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
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

  #3 (permalink)  
Old February 22nd, 2010, 04: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
  #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?
  #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/
  #6 (permalink)  
Old November 30th, 2013, 12:15 PM
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?


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.