Click here to Skip to main content
15,908,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Actually i am using String Builder to Filter data, i have used various filters by using string builder, and at finally i used this:

dsDetails.Tables["CertificationDetails"].DefaultView.RowFilter = sbRowFilter.ToString();,

this is Giving Exception to me that :
Cannot perform '=' operation on System.String and System.Int32.

Please Help ME ASAP


C#
if (DepartmentID > 0)
                     {
                         if (string.IsNullOrEmpty(sbRowFilter.ToString()))
                         {
                             sbRowFilter.Append("ISDepartmentMatch '=' 1");

                         }

                     }


After This i Called:
dsDetails.Tables["CertificationDetails"].DefaultView.RowFilter = sbRowFilter.ToString();
Posted
Updated 29-Jul-13 7:44am
v2
Comments
CHill60 29-Jul-13 13:13pm    
What's in sbRowFilter?
CHill60 29-Jul-13 13:21pm    
By posting your code as a solution to your own question you have removed it from the Unanswered questions list. All I wanted to know was what is the content of sbRowFilter. You might want to use the Improve Question link to put your code into the question and delete your "solution"
vana Bharadwaj 29-Jul-13 13:26pm    
if (DepartmentID > 0)
{
if (string.IsNullOrEmpty(sbRowFilter.ToString()))
{
sbRowFilter.Append("ISDepartmentMatch = 1");

}

}
i Am Using this to Filter Department Data, [ISDepartmentMatch Type is Boolen.]
CHill60 29-Jul-13 13:31pm    
What is the content of sbRowFilter ... i.e. if you debug and hover over the variable what shows up ... hint ... I'm looking for a single string value surrounded by quotes
vana Bharadwaj 29-Jul-13 13:38pm    
Actually i have created a sting builder and in that i have used ISDepartmentMatch as BOOl value and after that i have Checked if the value came from Sp and value that is user passed from Is same, then return True and
dsDetails.Tables["CertificationDetails"].DefaultView.RowFilter = sbRowFilter.ToString();,

This used to append tht filter data in that Stringbuilder to Dataset, so the problem is it is taking IsDepartment=1 as a string, so how to slove this?
Thanks in advance.

C#
sbRowFilter.Append("ISDepartmentMatch= '1'");


The error is telling you that it can't convert an integer to string. Place single quotes around the value and remove the single quotes around the equal sign.
 
Share this answer
 
Comments
CHill60 29-Jul-13 14:16pm    
My 5 - although as I've posted in reply to the OP he'll probably hit the same issue on some of the other columns *sigh*
vana Bharadwaj 29-Jul-13 14:52pm    
MR Chill60 and ryanb31
Thanks for your suggestion. i resloved it. :)
ZurdoDev 29-Jul-13 15:07pm    
Glad to hear.
The error says Cannot perform '=' operation. You should not wrap logical operator = with single quotes. Remove quotes from = operator and try again
 
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