FilterS+="项目名称='"+listBox2.Items[j].ToString()+"'or"; 这个是什么意思

解决方案 »

  1.   

    应该这样用:
    名字='aaa' or 年龄=100
    你的or没有后面的部分
      

  2.   

    就是想让DATAGRID显示项目名称为LISTBOX2中的值的所有行
      

  3.   

    DataView dv = ds.Tables["项目表"].DefaultView;
    int m = listBox2.Items.Count;
    string FilterS = "";
    for(int j = 0; j < m; j++)
    {
        FilterS+="项目名称='"+listBox2.Items[j].ToString()+"'or";
    }
    FilterS = FilterS.Substring(0,FilterS.Length - 2); //将最后一次加的or去掉
    dv.RowFilter = FilterS;
    dataGrid1.DataSource = dv;
      

  4.   

    对上面的问题补充:(你要注意留空格,并减掉最后的'or '字符.
    Filters+="项目名称='"+listBox2.Items[j].tostring()+"' or ";
      

  5.   

    你调试出FilterS的结果不就成立吗?我看一般是“项目”前的空格问题—————————————————————————————————
      

  6.   

    结果为 a or b or 
    后面没有当然不行了
    改成 or a or b 试试
      

  7.   

    1://FilterS+="项目名称='" + listBox2.Items[j].ToString()+"'or";
    FilterS += "项目名称='" + listBox2.Items[j].ToString() + "' or ";2://FilterS = FilterS.Substring(0,FilterS.Length - 2); 
    FilterS = FilterS.Remove(FilterS.Length -4,4);