Sir I am doing a error prone project at the moment.
I have a comboBox and a textbox.
the combobox stands for coutry list and textbox for phone number.
when i select a country from the combobox list, i need that country's code to be enter automatically to the taxtbox.
also the value entered in the textbox doesn't be removed when i enter phone number in it
please help me on this topic
Loading

Iftikar HussainPosted Jul 5, 2013, 5:22 AM
You can do like below
Regards,
Iftikar
Sanjeeb LenkaPosted Jul 5, 2013, 5:23 AM
bind your combo box like this
SqlConnection con = new SqlConnection("your connection string");
SqlCommand cmd = new SqlCommand("select Countrycode,Countryname from countrytable", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
comboBox1.ValueMember = "Countrycode";
comboBox1.DisplayMember = "Countryname";
comboBox1.DataSource = ds.Tables[0];
then in comboBox1_SelectedIndexChanged event write the below code
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
textBox1.Text = comboBox1.SelectedValue.ToString();
}
any problem reply
Bineesh ViswanathPosted Jul 5, 2013, 5:07 AM
the possible contents you given is not a relation with my project
Iftikar HussainPosted Jul 5, 2013, 5:02 AM
Are you trying to do this in WebApplication or WindowsApplication?
Regards,
Iftikar