954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to bind dropdown to a datasource

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....

navvin_20
Newbie Poster
5 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

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.

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 
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....

navvin_20
Newbie Poster
5 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

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

Jens
Light Poster
49 posts since Apr 2008
Reputation Points: 13
Solved Threads: 6
 

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...

navvin_20
Newbie Poster
5 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

Not a problem, hope it helped.

Jens
Light Poster
49 posts since Apr 2008
Reputation Points: 13
Solved Threads: 6
 

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;

ushalakshmi
Newbie Poster
2 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You