Click here to Skip to main content
14,170,500 members
Rate this:
 
Please Sign up or sign in to vote.
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]
Posted
Updated 6-Nov-11 2:52am
v2
Comments
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.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
eventname()
{
  //value to Textbox
}

If it's a web application then you need to set Autopostback=True for Combobox(Dropdownlist.)
   
Comments
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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)
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.190524.1 | Last Updated 6 Nov 2011
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100