我有个SqlParameter想通过DDL的SELECTCHANGE事件取值,中间用了个LABEL过渡一下,代码如下    protected void txtCategory_SelectedIndexChanged(object sender, EventArgs e)
    {
        lbCategory.Text = txtCategory.SelectedValue;
    }        SqlParameter kcnow = new SqlParameter("@KCNOW", SqlDbType.Char);
        if (lbCategory.Text.Trim() == "5")
        {
            kcnow.Value = "0";
            Response.Write("<script type='text/javascript'> alert('0');</script>");
        }
        if (lbCategory.Text.Trim() == "6")
        {
            kcnow.Value = "0";
            Response.Write("<script type='text/javascript'> alert('0');</script>");
        }
        if (lbCategory.Text.Trim() == "7")
        {
            kcnow.Value = "0";
            Response.Write("<script type='text/javascript'> alert('0');</script>");
        }
        else
        {
            kcnow.Value = "1";
            Response.Write("<script type='text/javascript'> alert('1');</script>");
        }
        parameters[11] = kcnow;
结果在对比过程中,当等于“5”和“6”的时候,弹出信息出现2次,一次为“0”,第二次为“1”,但当等于“7”的时候就显示一次为“0”,不知道出了什么问题,有人能解决或提出解决思路吗?急!!!DDL  取值

解决方案 »

  1.   

     if (lbCategory.Text.Trim() == "5")
            {
                kcnow.Value = "0";
                Response.Write("<script type='text/javascript'> alert('0');</script>");
            }else 
            if (lbCategory.Text.Trim() == "6")
            {
                kcnow.Value = "0";
                Response.Write("<script type='text/javascript'> alert('0');</script>");
            }else
            if (lbCategory.Text.Trim() == "7")
            {
                kcnow.Value = "0";
                Response.Write("<script type='text/javascript'> alert('0');</script>");
            }
            else
            {
                kcnow.Value = "1";
                Response.Write("<script type='text/javascript'> alert('1');</script>");
            }
      

  2.   

    逻辑问题,先if 等于5 弹出0,然后会进行是否是7的判断,不是7 则else 弹出1,这个没什么奇怪的吧