SPGridView Gotcha: Filtering, ObjectDataSource and You

5 September 2012

Giving the SPGridView a good kick around today, seeing if it'll fit the bill for our development work - I came across two really great resources which I highly recommend for anyone looking to get a SPGridView up and going:

So following those posts, I got my SPGridView up and going and everything seemed to be in working order, except the Filtering which even after following the apostrophe notes kept returning the "Missing operand after 'x' operator" error message.

After some trial and error, it turns out that the column name needs to be one single word. I was filtering on a column named Time Elapsed in the back end, ie:

column = new BoundField();
column.DataField = "Time Elapsed";            
column.SortExpression = "Time Elapsed";
column.HeaderText = "Time Elapsed";            

When I renamed the DataField and Sort Expression to "TimeElapsed" instead (leaving the header text as two words), all my errors disappeared and everything went great! I don't know if they never tested the "Total Sales" filtering in the examples linked to on Erik's blog, but this fixed it for me so it's one more thing to try for anyone who's getting errors while filtering.

Tags: SPGridView, filtering, SharePoint 2010

Add a Comment

No Comments