日期:2014-05-18  浏览次数:20992 次

读取下拉框的值
下拉框 我是绑定到 数据库中一个表中 item_no 字段
选择 下拉框中的值 然后 按钮 触发事件 将 选中的值 写入到 LABLE中

 
C# code
 SqlDataReader read1 = SqlHelper.ExecuteReader(common.GetConnStr(), CommandType.Text, "select  top 20  * from item ", null);
        DropDownList1.DataSource = read1;
        DropDownList1.DataTextField = "item_no";
        DropDownList1.DataBind();

 protected void Button1_Click(object sender, EventArgs e)
    {
        this.Label1.Text = DropDownList1.SelectedValue.ToString();
    }



现在 不管如何 选择 下拉框的值 始终读取的下拉框中第一个值 ,不知错在哪里?

------解决方案--------------------
SqlDataReader read1 = SqlHelper.ExecuteReader(common.GetConnStr(), CommandType.Text, "select top 20 * from item ", null);
DropDownList1.DataSource = read1;
DropDownList1.DataTextField = "item_no";
DropDownList1.DataBind();
这个是写到Page_Load里面的? && 没有用 if(!Page.IsPostBack)包起来?