943,557 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 17675
  • C# RSS
Apr 22nd, 2008
0

how to bind dropdown to a datasource

Expand Post »
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....
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
navvin_20 is offline Offline
5 posts
since Apr 2008
Apr 22nd, 2008
0

Re: how to bind dropdown to a datasource

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.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Apr 23rd, 2008
0

Re: how to bind dropdown to a datasource

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....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
navvin_20 is offline Offline
5 posts
since Apr 2008
Apr 23rd, 2008
0

Re: how to bind dropdown to a datasource

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
Reputation Points: 13
Solved Threads: 6
Light Poster
Jens is offline Offline
47 posts
since Apr 2008
Apr 23rd, 2008
0

Re: how to bind dropdown to a datasource

Click to Expand / Collapse  Quote originally posted by Jens ...
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...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
navvin_20 is offline Offline
5 posts
since Apr 2008
Apr 24th, 2008
0

Re: how to bind dropdown to a datasource

Not a problem, hope it helped.
Reputation Points: 13
Solved Threads: 6
Light Poster
Jens is offline Offline
47 posts
since Apr 2008
Apr 25th, 2008
0

Re: how to bind dropdown to a datasource

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;
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ushalakshmi is offline Offline
2 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Creating a Script Language In C#
Next Thread in C# Forum Timeline: Datagrid





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC