User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 423,303 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,282 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 2132 | Replies: 6
Reply
Join Date: Apr 2008
Posts: 5
Reputation: navvin_20 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
navvin_20 navvin_20 is offline Offline
Newbie Poster

how to bind dropdown to a datasource

  #1  
Apr 22nd, 2008
Hi I am a beginner to asp.net.
Could any one please help me ...
I have a database table with two colums ( column one has all the countries and column two has all the capitols of that particular country.)

In my .aspx page I have a dropdown list and a text box.
Drop downlist will display all the countries and if I select a country then its capitol should be displayed in the textbox.

Thanks in Advance...
Your help is much appreciated....
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 762
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 59
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: how to bind dropdown to a datasource

  #2  
Apr 22nd, 2008
From DropDownList properties assign its DataSource to your created datasource, then choose which column to be shown and which to be the value of the items. All from properties or the smart arrow which located on the top left of the DropDownList.
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Join Date: Apr 2008
Posts: 5
Reputation: navvin_20 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
navvin_20 navvin_20 is offline Offline
Newbie Poster

Re: how to bind dropdown to a datasource

  #3  
Apr 23rd, 2008
Originally Posted by RamyMahrous View Post
From DropDownList properties assign its DataSource to your created datasource, then choose which column to be shown and which to be the value of the items. All from properties or the smart arrow which located on the top left of the DropDownList.



Hi Ramy Thanks a lot for ur reply.....
but how do I need to display the corresponding value of dropdownlist selected value in the text box, without posting back to the server.

Thanks so much again.....in advance....
Reply With Quote  
Join Date: Apr 2008
Location: Belgium
Posts: 47
Reputation: Jens is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
Jens's Avatar
Jens Jens is offline Offline
Light Poster

Re: how to bind dropdown to a datasource

  #4  
Apr 23rd, 2008
That is handled in a handler in your dropdown. You can try the selectedvaluechanged - handler for that.

The value of your dropdownlist then gets sent through the sender of your listener.

Hope this helps, jens
Reply With Quote  
Join Date: Apr 2008
Posts: 5
Reputation: navvin_20 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
navvin_20 navvin_20 is offline Offline
Newbie Poster

Re: how to bind dropdown to a datasource

  #5  
Apr 23rd, 2008
Originally Posted by Jens View Post
That is handled in a handler in your dropdown. You can try the selectedvaluechanged - handler for that.

The value of your dropdownlist then gets sent through the sender of your listener.

Hope this helps, jens


Thanks Jens for you reply...
Reply With Quote  
Join Date: Apr 2008
Location: Belgium
Posts: 47
Reputation: Jens is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
Jens's Avatar
Jens Jens is offline Offline
Light Poster

Re: how to bind dropdown to a datasource

  #6  
Apr 24th, 2008
Not a problem, hope it helped.
Reply With Quote  
Join Date: Apr 2008
Posts: 2
Reputation: ushalakshmi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ushalakshmi ushalakshmi is offline Offline
Newbie Poster

Re: how to bind dropdown to a datasource

  #7  
Apr 25th, 2008
Hi,

u can bind dropdown list to a datasource by giving as

dropdownlist.DataTextfield="Countris";
dropdownlist.DataValuefield="Columns";

and in dropdownlist_selectindex change event write

textbox.text=dropdownlist.selectedvalue;
Reply With Quote  
Reply

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

DaniWeb C# Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C# Forum

All times are GMT -4. The time now is 11:01 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC