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.
strFilter's value when it hits that line? - Matt Hamiltonstring strFilter= " 0=0 ";? - MaysamstrFilter) is that your "SampleSession" variable has a single-quote character in it which is breaking the expression. Sort of a poor-man's SQL injection vulnerability. Could you possibly be passing an employee name like "Bob O'Hara"? - Matt HamiltonstrFilter, you wasted a number of people's time trying to answer a question that did not contain the problem. Just a recommendation for the future: post code that actually causes the problem; since you (by definition) don't understand the issue, it is all too easy to accidentally remove the actual cause when posting a question. - Marc Gravell