我正在使用数据 View 过滤我的 GridView 。我正在将过滤器命令传递给数据 View ,如下所述;
string strFilter= " 0=0 ";
if (Session["SampleSession"] != null)
{
strFilter= strFilter+ " and Emp Name = '" + Session["SampleSession"].ToString() + "' ";
}
dv.RowFilter = strFilter; // Throws an error here!
它在上一行中抛出 Missing operand after 'Operator Name' operator 的错误。
我相信有一个我无法捕捉到的小错误。
最佳答案
你的问题是“Emp Name”(列名)包含一个空格,需要在过滤表达式中用方括号括起来:
strFilter= strFilter+ " and [Emp Name] = '" + Session["SampleSession"].ToString() + "' ";
关于c# - 'Operator Name' 运算符后缺少操作数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6978157/