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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 serveryou meanon the controllerthat’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.