RSS Forums RSS
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 9435 | Replies: 3
Reply
Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

Help how to create a dynamic dropdownlist?

  #1  
Dec 22nd, 2005
hi all,
do anyone knows how to create a dynamic dropdownlist? the dropdownlist will retrieve the list items from database..

eg: below is code for static dropdownlist where i declare the listitem myself.. but how should i declare listitem retreive from database?
<asp:dropdownlist id="ddl" Runat="server">		
             <asp:ListItem Value="1">A</asp:ListItem>	<asp:ListItem Value="2">B</asp:ListItem>	<asp:ListItem Value="3">C</asp:ListItem>
</asp:dropdownlist>

thanks..
cheers,
ohgosh
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 482
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: how to create a dynamic dropdownlist?

  #2  
Dec 22nd, 2005
what kind of database are you using, SQL, access?
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 482
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: how to create a dynamic dropdownlist?

  #3  
Dec 22nd, 2005
if you can get the information out of the database and into a DataTable all you need to do is:
DropDownList1.DataSource=dataTableName;
			DropDownList1.DataTextField="NameofDatabaseColumn";
			DropDownList1.DataValueField="NameofDatabaseColumn";
			DropDownList1.DataBind();

if you need help getting it from the database into the datatable let me know
Reply With Quote  
Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

Re: how to create a dynamic dropdownlist?

  #4  
Dec 23rd, 2005
Originally Posted by campkev
what kind of database are you using, SQL, access?

im using ms sql server 2000.. well, i will try the code later

thanks 4 ur help..
cheers,
ohgosh
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:08 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC