Missing operand after operator "Operator Name"

I am filtering my gridview using dataview. I pass the filter command to the dataview as follows;

string strFilter= " 0=0 "; if (Session["SampleSession"] != null) { strFilter= strFilter+ " and Emp Name = '" + Session["SampleSession"].ToString() + "' "; } dv.RowFilter = strFilter; // Throws an error here! 

It gives the error "There is no operand after the operator" Operator Name "in the above line.

I believe that there is a small mistake that I cannot catch.

+4
source share
1 answer

Your problem is that the name β€œEmp Name” (column name) contains a space and must be enclosed in square brackets in the filter expression:

 strFilter= strFilter+ " and [Emp Name] = '" + Session["SampleSession"].ToString() + "' "; 
+11
source

All Articles