da.Fill(ds, "用户");  之后,用户里有四列,但是有的控件datasource其中的一列,该如何做呢,该用什么对象把其中的一列分解出来呢,          

解决方案 »

  1.   

    看什么控件喽
    不一定要分离出来的如DropDownListDropDownList1.DataSource=da.Fill(ds, "用户");  
    DropDownList1.DataTextField="列名";
    DropDownList1.DataBind();
      

  2.   

    其实就是这样:用一个for循环遍历arraylist al;
    string str;
    for(int i=0;i<ds.table["用户"].Rows.count;i++)
    {
      str= ds.table["用户"].Rows[i]["这里写数据库里你要的列名"].ToString();
      al.add(str);
    }然后数据库里你想要的列,就都在al里了!!
      

  3.   

    ds.Tables[0].Columns[0]数据集的第0个Table的第0列
      

  4.   

    登录名.DataSource = ds.Tables["用户"].Columns[1];   登录名为comobox,为什么报错呢
      

  5.   

    若是ComboBox的,下面的方法可能对你有用 //初始化 ComboBox 列表
    internal bool init_cbxList(SqlConnection conn, string strSelect, ComboBox cbxList, string displayColumn, string valueColumn)
    {
    //
    cbxList.DataSource = null;
    cbxList.DisplayMember = null;
    cbxList.ValueMember = null; SqlDataAdapter newDA = new SqlDataAdapter(strSelect, conn);
    DataSet newDS = new DataSet();
    try
    {
    newDA.Fill(newDS,"newTable");
    }
    catch
    {
    return false;
    }
    if(newDS.Tables["newTable"].Rows.Count > 0)
    { cbxList.DataSource = newDS.Tables["newTable"];
    cbxList.DisplayMember = displayColumn;
    cbxList.ValueMember = valueColumn;
    }
    return true;
    }