我想从datagridview组合框中选择一个值,从数据库中提取到datagridview文本框。当我选择任何药物名称时,请在图像中查看应从数据库中提取unitprice。怎么办?
SqlConnection con = new SqlConnection(connection string);
con.Open();
SqlDataAdapter adp = new SqlDataAdapter("select quantity,unitprice,totalprice from stock where medicinename='" + dataGridView1.Columns[0].ToString() + "' ", con);
DataSet ds = new DataSet();
adp.Fill(ds);
dataGridView1.DataSource = ds;
dataGridView1.Columns[1].DataPropertyName = "quantity";
dataGridView1.Columns[2].DataPropertyName = "unitprice";
dataGridView1.Columns[3].DataPropertyName = "totalprice";
con.Close();