Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am filtering my gridview using dataview. I am passing the filter command to dataview as mentioned below;

C#
string strFilter= " 0=0 ";  
  
if (Session["SampleSession"] != null)     
{       
  strFilter= strFilter+ " and EmpName = '" + 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.

Please guide me!
Posted
Updated 7-Aug-11 20:51pm
v3
Comments
walterhevedeich 8-Aug-11 2:48am    
Are you sure EmpName does not contain spaces? It seems to me its because a field name has a space on it and you might want to wrap that with [] to make it work.
Mohammad A Rahman 8-Aug-11 3:23am    
May be you need to check first bit of your string which is
string strFilter= " 0=0 "; Not Sure what would you mean by "0=0" ? Please put bit more information :)

Try using the @ directive in the strFilter clause.
string strFilter= @" 0=0 "; 
if (Session["SampleSession"] != null)     
{       
  strFilter= strFilter+ @" and EmpName = '" + Session["SampleSession"].ToString() + "' ";     
} 
 
Share this answer
 
Where 'Operator Name' comes from? Debug your code well. You are appending to strFilter. What is the value of strFilter before and after that statement. If you cannot get the problem, post those values here.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900