roy himanshu

roy himanshu

  • NA
  • 126
  • 0

how to Data displayed in textboxes with the help of Combobox?

Sep 17 2009 6:55 AM

Hello,

Please help!!!

I am working in C#.I have a form that a combo box and Three Text box.The combo box contains Item codes. when i select a item code in combo box then related data (Item Name,price,Quantity) is displayed in three text boxes.But i get only one value in textboxs. plz solve my problem.My code past here.

private
void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
string s;
s = comboBox2.ToString();
cn =
new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["con"]);
SqlCommand cmd=new SqlCommand ("select column003,column005,column007 from CATABLE004 where column002='" + s + "'",cn);
da2 =
new SqlDataAdapter();
ds =
new DataSet();
cmd.Connection = cn;
da2.SelectCommand = cmd;
da2.Fill(ds,
"CATABLE004");
textBox2.Text = comboBox2.SelectedValue.ToString();
textBox3.Text = comboBox2.SelectedValue.ToString();

 
}

 

Answers (4)