I understand how to add columns with Razor syntax in the view but I was wondering if there is a way to create the WebGridColumns on the server side and hand it off to the WebGrid.GetHtml method on the razor side?
Razor runs on the server, so when you are declaring your columns in your view, the grid is already created on the server. But if by on the server
you mean on the controller
that's a different story. But, yes, sure, you could do it. Just define a property on your view model (the class passed to your view by the controller action) which is a collection of the columns.