I am filtering my gridview using dataview. I am passing the filter command to dataview as mentioned below;
string strFilter= " 0=0 ";
if (Session["SampleSession"] != null)
{
strFilter= strFilter+ " and Emp Name = '" + Session["SampleSession"].ToString() + "' ";
}
dv.RowFilter = strFilter; // Throws an error here!
It throws an error of Missing operand after ‘Operator Name’ operator in above line.
i believe there is small error which i am unable to catch.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Your problem is that “Emp Name” (the column name) contains a space and needs to be wrapped in square brackets in the filter expression:
strFilter= strFilter+ " and [Emp Name] = '" + Session["SampleSession"].ToString() + "' ";
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0