Is this is rigid query? (Are you building something that hopes to work with any sql query or a specific one?)
Instead of trying to manipulate the sql query, it would probably be easier to manipulate the grid. After you bind the grid, you could modify the column settings in the grid to turn on/off the columns according to the checkbox states.
-
Peter