DropDownList也LABEL的结合
大侠们,帮我一下,谁会用dropdownlist的DataValueField的值作为条件,查询数据库中的数据,让LABLE显示在页面上,但是重新选择了dropdownlist的值了,那LABLE显示的值也会变,这个功能谁会做啊,帮帮忙 --------------------编程问答-------------------- protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
ltrResult.Text = DropDownList1.SelectedItem.Text;
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
ltrResult.Text = DropDownList1.SelectedItem.Text;
} --------------------编程问答-------------------- 我想要的结果不是那样的啊,你看我的程序
string str6 = "SELECT customer_name,customer_id from tb_customer1";
da6 = sl6.getConnection(str6);
this.DropDownList7.DataSource = da6;
this.DropDownList7.DataTextField = "customer_name";
this.DropDownList7.DataValueField = "customer_id";
this.DropDownList7.DataBind();
protected void DropDownList7_SelectedIndexChanged(object sender, EventArgs e)
{ string values = DropDownList7.SelectedValue.Trim();
SqlConnection con = DB.createConnetion();
if (con.State == ConnectionState.Closed)
{
con.Open();
}
string sql = "select CASE_STATE from tb_case1 ";
string sqlstr1 = "select CASE_STATE from tb_case1 where tb_case1.CUSTOME_ID='" + values + "'";
SqlCommand cmd1 = new SqlCommand(sqlstr1, con);
SqlDataReader read = cmd1.ExecuteReader();
if (read.Read())
{
this.Label1.Text = read.GetValue(0).ToString();
}
这样,能不能实现那个功能。
我要的结果是:要输出的是CASE_STATE 的值 --------------------编程问答-------------------- 你能帮我看一下吗,谢谢 --------------------编程问答-------------------- 没人回答吗,帮一下
补充:.NET技术 , .NET Framework