Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello frnds,

on my webpage i have dropdownlist and a textbox.

in database i have a table(Departments), in this i have fields as Dept_code, Dept_desc
These dept_code and Dept_desc are filled in database with data in it.

In dropdownlist i have list of department codes. these departments am taking from database table.

for example : in database it is stored like this
Dept_code - IT
Dept_desc - Information Technology.

Now, if i select IT from dropdownlist, automatically Dept_desc must display in Textbox.

Based upon dropdown value it should retrieve and filled in textbox.

Please help me thanks.
Posted
Comments
PRAKASH9 24-Apr-13 9:03am    
use like this textbox1.text = dropdownlist.selectedvalue

in your dropdownlist selectedindexchanged event

Hi,

While binding data from database bind the dropdownlist.DisplayMember and dropdownlist.ValueMember, bind the displaymember to dept_code and valueMember to dept_description. then on dropdownlist selectedindexchanged event set the textbox value to dropdownlist's valuemember property.

If you don't understand this, plz give your code , i will guide you....
 
Share this answer
 
If you have the dept_desc data is not having any duplicates then you populate the dropdownlist like this
value should be dept_desc
text should be dept_code

So that it will display dept_code to the user. But this may break if the dropdownlist values has got any duplicate. So if your DB returns distinct descriptions then this would be fine.

While user change the dropdown , you can write a js function for the client side onChange event and get the SelectedItem.Value and then set this value to the textbox

If the desc is not unique then I think you will have to manipulate in an array. You can keep all those dec in client array and with the same index it populate to the dropdown. Then using the dropdown selected index can pick from the array and show to the textbox

Thanks,
Siju Thomas.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900