how to bind dropdown to a datasource

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 5
Reputation: navvin_20 is an unknown quantity at this point 
Solved Threads: 0
navvin_20 navvin_20 is offline Offline
Newbie Poster

how to bind dropdown to a datasource

 
0
  #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....
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: how to bind dropdown to a datasource

 
0
  #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.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 5
Reputation: navvin_20 is an unknown quantity at this point 
Solved Threads: 0
navvin_20 navvin_20 is offline Offline
Newbie Poster

Re: how to bind dropdown to a datasource

 
0
  #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 Quick reply to this message  
Join Date: Apr 2008
Posts: 47
Reputation: Jens is an unknown quantity at this point 
Solved Threads: 5
Jens's Avatar
Jens Jens is offline Offline
Light Poster

Re: how to bind dropdown to a datasource

 
0
  #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 Quick reply to this message  
Join Date: Apr 2008
Posts: 5
Reputation: navvin_20 is an unknown quantity at this point 
Solved Threads: 0
navvin_20 navvin_20 is offline Offline
Newbie Poster

Re: how to bind dropdown to a datasource

 
0
  #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 Quick reply to this message  
Join Date: Apr 2008
Posts: 47
Reputation: Jens is an unknown quantity at this point 
Solved Threads: 5
Jens's Avatar
Jens Jens is offline Offline
Light Poster

Re: how to bind dropdown to a datasource

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

Re: how to bind dropdown to a datasource

 
0
  #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 Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC