不知道了
不过我在VS2003里如果在if(!IsPostBack)之后帮定也会是空值,在之前就正常了
取到的值也是正常的
建议你跟踪一下看看哪里出的问题

解决方案 »

  1.   

    if (DropDownList1.Items.Count < 1)去掉这个if看看
      

  2.   

    foreach
    foreach是只读的,循环内不能进行赋值等操作,改成FOR试试
      

  3.   

    还有就是dropdownlist不要用ds绑定,用datareader循环赋值试试,貌似用ds绑定是会有这个问题
      

  4.   

    VS2005, 你不需要编代码了,用SqlDataSource,配置一下,搞定.
      

  5.   

    你是不是把Dropdownlist的EnalbeViewState设置成false了?
      

  6.   

    protected void Page_Load(object sender, EventArgs e)
    {
    if(!IsPostBack)

      ddl.Items.Insert(0, new ListItem("商品大类"));
    }
    bindlist();
    }
    public void bindlist()
    {if (DropDownList1.Items.Count < 1)
    {
    int i=DropDownList1.selectindex;
    csml_DB myml = new csml_DB("");
    // foreach (DataRow name in myml.csml_List().Tables[0].Rows)// DropDownList1.Items.Add(name[2].ToString());
    DropDownList1.DataSource = (myml.csml_List());
    DropDownList1.DataTextField= "type_name";
    DropDownList1.DataValueField = "type_name";
    DropDownList1.selectindex=i;
    DropDownList1.DataBind();
    }
    }
      

  7.   

    要允许DropDownList的EnableViewState
      

  8.   

    if (csml_DB.fl_and(DropDownList1.SelectedValue.ToString(), "dddddd3")) Response.Write("<script>('增加分类完成')</script>");这个好象有问题,
    分步用索引index来解决
      

  9.   

    把dropdownlist的autoback属性改为true 看看
      

  10.   

    我的和他的有点不一样,我是JS赋值进去的
    document.getElementById("WebCombo1_input").value = rd.parentNode.parentNode.cells[1].innerText;但是感觉页面上好像值是对的,控件认的值仍然是以前的那个值
      

  11.   

    试试用“Request.Form[this.DropDownList1.ClientID]”来获取DropDownList1的选择值。
    我以前有时候取不到DropDownList的值,换成上面的写法就能取到了。
    string s = Request.Form[this.DropDownList1.ClientID];
      

  12.   

    我是在页面load的时候绑定的
     protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                SqlConnection conn = new SqlConnection();
                conn.ConnectionString = Session["Conn"].ToString();            DataSet ds = new DataSet();            string strCom = "select distinct Log09003 from Log09 ";
                SqlDataAdapter ada1 = new SqlDataAdapter(strCom, conn);
                ada1.Fill(ds, "JL01");            WebCombo1.DataSource = ds.Tables["JL01"];
                WebCombo1.DataTextField = "Log09003";
                WebCombo1.DataValueField = "Log09003";
                WebCombo1.DataBind();
            }
        }上手WebCombo1的disDisplayValue里面是空值然后用JS赋值
    document.getElementById("WebCombo1_input").value = rd.parentNode.parentNode.cells[1].innerText;然后按button做操作的时候,却仍然是空值protected void IMB_DEL_Click(object sender, ImageClickEventArgs e)
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = Session["Conn"].ToString();        int SubjectNum = int.Parse(this.Session["SubjectNum"].ToString());        int Log09001 = SubjectNum;
            string Log09002 = Session["UserId"].ToString();
            string Log09003 = WebCombo1.DisplayValue.ToString();
            string Log09004 = TextBox1.Text.ToString();        string strCom = "delete from Log09 where Log09001 = " + SubjectNum + " and Log09002 = '" + Log09002 + "' and Log09003='" + Log09003 + "' and Log09004 = '" + Log09004 + "'";
            SqlCommand Log09_Del = new SqlCommand(strCom, conn);
            conn.Open();
            Log09_Del.ExecuteNonQuery();
            conn.Close();
        }用了Request.Form[this.WebCombo1.ClientID].ToString();也是这个情况,不知道是什么原因头发要白咯
      

  13.   

    -------------------------------------------------------
    string Log09003 = WebCombo1.DisplayValue.ToString();
    -------------------------------------------------------
    DropDownList 还有 DisplayValue 这个属性呢?? 我怎么点不出来???
      

  14.   

    是WebCombo拉,DisplayValue就是和textBox的text属性是一样的
      

  15.   

    那是因为你POSTBACK!不想POSTBACK用AJAX吧Q@