Welcome to Office Zealot Sign in | Join | Help

SPGridView - syntax error: missing operand after ‘X’ operator

I was building a custom SharePoint 2010 web part recently and was using the SPGridView to show results in a standard grid.  I wanted to add sorting and filtering on the grid (my next blog post will show coding details on this) and used the three lines below to enable filtering from the column headers:

grd.FilterDataFields = “,,Status,Type,,,,”;

grd.FilteredDataSourcePropertyName = “FilterExpression”;

grd.FilteredDataSourceProertyFormat = “{1} = ‘{0}’”;

The code worked fine until I changed the first line to enable an additional column:

grd.FilterDataFields = “,,,Status, Type, Part Vendor,,,”;

Then, I got the following error:

“syntax error: missing operand after Vendor operator”

Quick analysis led me to realize that the issue was the space between ‘Part’ and ‘Vendor’ in the field name.  I changed the third line to the following and all was good:

grd.FilteredDataSourceProertyFormat = “[{1}] = ‘{0}’”;

 

Published Tuesday, November 01, 2011 6:00 AM by Mauro
Filed under: ,

Comments

# Sharepoint Updates November-01-2011 | SDavara's Sharepoint Knowledge Center

Anonymous comments are disabled