表:table_name 的字段:aa 的赋值给 DropDownList1,结果出错显示1 5 或者 1 0 这样的数字?
        DataSet ds1 = new DataSet();
        da.Fill(ds1, "table_name");
        this.DropDownList1.DataSource = ds1.Tables ["table_nale"].Rows[1][1].ToString() ;
        this.DropDownList1.DataBind();

解决方案 »

  1.   

     this.DropDownList1.DataSource = ds1.Tables ["table_nale"].Rows[1][1].ToString() ;
    这句有问题,这个地方要用 ds1.Tables ["table_nale"]
    如果想赋单个值可以这样写
    DropDownList1.Item.Add(ds1.Tables ["table_nale"].Rows[1][1].ToString());
    然后,可以根据你赋值的Item来设置他的Text和value
      

  2.   

    同意楼上说法,要把某个字段赋值给DropDownList1,还需要调用另外两个属性,设置值字段和现实字段
      this.DropDownList1.DataSource = ds1.Tables ["table_nale"] ;  this.DropDownList1.DataBind();
      

  3.   

    设置 this.DropDownList1.DataTextField和DataValueField
      

  4.   

      DataSet ds1 = new DataSet();
      da.Fill(ds1, "table_name");
      this.DropDownList1.DataSource = ds1.Tables ["table_nale"];
      this.DropDownList1.DataTextField = "aa";
      this.DropDownList1.DataValueField = "aa";
      this.DropDownList1.DataBind();
      

  5.   

    添加 DropDownList1 另外两个属性值   DataTextField 、DataValueField
      

  6.   

    按照如下代码:提示错误:databingding "system.data.datarowviw"不包含名为:"aa"的属性????
    DataSet ds1 = new DataSet();
      da.Fill(ds1, "table_name");
      this.DropDownList1.DataSource = ds1.Tables ["table_nale"];
      this.DropDownList1.DataTextField = "aa";
      this.DropDownList1.DataValueField = "aa";
      this.DropDownList1.DataBind();
      

  7.   

    DataSet ds1 = new DataSet();
      da.Fill(ds1, "table_name");
      this.DropDownList1.DataSource = ds1.Tables ["table_name"];
      this.DropDownList1.DataTextField = "aa";
      this.DropDownList1.DataValueField = "aa";
      this.DropDownList1.DataBind();按照如下代码:提示错误:databingding "system.data.datarowviw"不包含名为:"aa"的属性????
      

  8.   

    因为查询的是三个表.sql语句有问题所以才报的错.单表查询没问题.
      

  9.   

    检查sql语句,看看你的列名是什么
      

  10.   

    select (select count(*) from t1),* from t1,t2,t3 
      this.DropDownList1.DataSource = ds1.Tables ["t2"];
      this.DropDownList1.DataTextField = "t2_aa";
      this.DropDownList1.DataValueField = "t2_aa";
      this.DropDownList1.DataBind();
      

  11.   

    字段有重名的,建议使用as 取别名在绑定
    select  a as b from tale