i made two dropdowns and 1 lable.
1.ddCategory dropdown
2.ddProduct dropdown
3.Price lable
i hvae 3 tables in database. 1st is CategoryData 2nd is ProductData and 3rd is is PriceData
CAtegoryData is databound to ddCategory // (Id,CAtegory_Id,Name)4 categories
ProductData is databound to ddProduct // ((Id,Category_Id,Product_Name)8 Product in each category
Pricedata has price. (Id,Category_Id,Price)
user select category. product are shown of the selected category. and then the price should be displayed on the lable.
i just couldn't display price into the lable.
i guess my select statement is wrong.
code here, please help asap
SqlCommand cmd = new SqlCommand("Select * From PriceData Where Id ='" + ddCategory.SelectedValue + "'", con);
cmd.Parameters.AddWithValue("@Price", ddProduct.SelectedItem.Value);
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
Price.Text = sdr["Price"].ToString();
}