函数GetDataSat(sqlstring)返回一个查询的dataset,现在需要将其放入到数组中,请各位帮忙一下给出完整的代码(包括变量定义的),不胜感激!!
鄙人的原始问题是 根据select的返回值(只有一列)来确定checkBox.checked的状态,即checkBox1.text的值在select的结果集中,checkBox1.checked=true;(有好多个checkBox,鄙人也不会循环)
已有函数GetDataSat(sqlstring);
不知道那位好心人提供一些好的方法的代码!!

解决方案 »

  1.   

    string[] arr=new string[ds.Tables[0].Rows.Count];
    for(int i=0;i<ds.Tables[0].Rows.Count;i++)
    {
    arr[i]=ds.Tables[0].Rows[i].ToString();
    }
      

  2.   

    我是不会控件的循环,例如:(假设控件都有的话)
    for(i=0;i<10,i++)
    {
    CheckBox[i]=TextBox[i].Text
    }
    正确的写法是怎么样的??
      

  3.   

    这个东西..有点像是在做权限.呵..
    如果是考虑列值到bool型的快速转换的话.不妨试试将值累加走来.
    如SQL查询返回一个类似"0101010111"的串.
    然后使用SubString()取相应的位.
    ---------------------------------
    1楼可以优化一下.折半.
    int count = ds.Tables[0].Rows.Count;
    string[] arr=new string[count]; 
    for(int i=0;i <count;i++)
    {
        int temp = count - i - 1;
       if (i < temp)
       {
           arr[i]=ds.Tables[0].Rows[i].ToString(); 
           arr[temp ]=ds.Tables[0].Rows[temp].ToString(); 
       }
       else
       {
          break;
       }
    }
      

  4.   

    不是有个CheckBoxList控件吗?用它就可以了,难道你是拖了N个CheckBox控件?额滴乖乖```