如何获取标签(打印出来)取决于从下拉列表中选择的数据。
到目前为止代码
public partial class _Default : Page
{
DataSet ds = new DataSet();
MySqlConnection cs = new MySqlConnection(@"SERVER= ***.***.**.***;username=*****;password=***; Initial Catalog = dbname");
MySqlDataAdapter da = new MySqlDataAdapter();
protected void Page_Load(object sender, EventArgs e)
{
MySqlCommand cd = new MySqlCommand("SELECT * FROM pets", cs);
cs.Open();
MySqlDataReader ddl = cd.ExecuteReader();
DdPetPist.DataSource = ddl;
DdPetPist.DataValueField = "Specie";
DdPetPist.DataTextField = "Specie";
DdPetPist.DataBind();
cs.Close();
cs.Dispose();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
MySqlCommand cd = new MySqlCommand("SELECT CAST(Specie AS varchar) + '#' + CAST(Specie_Price AS varchar) AS Specie FROM pets");
}
所以我需要的是如果选择下拉的狗有标签说狗是20英镑,如果猫30英镑等,我知道我将需要一个开关声明,但我不知道如何使用数据库中的数据