Click here to Skip to main content
15,795,793 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am doing a project in that i could stuck i need a solution
when i select combobox value the textbox vzlue must change based on sql server 2008r2
plz do reply
i would be thankful if u solve my problem

[edit]Urgency deleted - OriginalGriff[/edit]
Updated 6-Nov-11 3:52am
OriginalGriff 6-Nov-11 8:52am    
Urgency deleted: It may be urgent to you, but it isn't to us. All that your stressing the urgency does is to make us think you have left it too late, and want us to do it for you. This annoys some people, and can slow a response.

It depends on how you do it.
If you are using a BindingSource to load the combobox, then set the DisplayMember to the appropriate field for display in the combobox, and the ValueMember to the field you want in the textbox.
Handle the ComboBox SelectedIndexdChanged event, and set the text:
private void MyComboBox_SelectedIndexChanged(object sender, EventArgs e)
    MyTextBox.Text =  MyComboBox.SelectedValue.ToString();

(You may want to put some error checking in there, but that gives you the idea)
Share this answer
Is it a Windows or web application? Here after come with your code

Write the code(Assign the value for the Textbox) in Combobox event like below.
  //value to Textbox

If it's a web application then you need to set Autopostback=True for Combobox(Dropdownlist.)
Share this answer
KhushbooJajoo 7-Nov-11 10:31am    
It is a windows form
I m using stored procedure in sql server 2008r2
In stored procedure it returns a datarow based on id

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