Try this
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con1 = new SqlConnection("Your Connection string");
SqlCommand cmd1 = new SqlCommand("select item_price from quantity where item_name=@item", con1);
cmd1.Parameters.Add("@item", DropDownList1.SelectedItem.Text);
SqlDataAdapter sda1 = new SqlDataAdapter(cmd1);
DataTable dt1 = new DataTable();
sda1.Fill(dt1);
if (dt1.Rows.Count > 0)
TextBox1.Text = dt1.Rows[0]["item_price"].ToString();
}
You should be aware of
SQL Injection[
^] when
hardcoding the SQl Statemetns