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 HussainRank #423 · 5.9K reputationPosted Jul 5, 2013, 1:22 AM EDT
You can do like below
Regards,
Iftikar
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 5, 2013, 1:02 AM EDT
Are you trying to do this in WebApplication or WindowsApplication?
Regards,
Iftikar
Bineesh ViswanathRank #1,681 · 907 reputationPosted Jul 5, 2013, 1:07 AM EDT
the possible contents you given is not a relation with my project
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jul 5, 2013, 1:23 AM EDT
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