I have a Car class that I\'m trying to display in an MVC 3 view using the WebGrid helper. Below are the Car and it\'s metadata class.
Car class:
[Meta
Ugly as hell but it could work:
grid.Column(
"CarName",
ModelMetadata.FromLambdaExpression(
car => car.CarName,
new ViewDataDictionary(new Car())
).DisplayName
)
The problem is that the WebGrid helper is entirely based on dynamic data, absolutely no strong typing and that's one of the reasons why I hate it. The WebMatrix team at Microsoft must be real fans of the C# 4.0 dynamic feature as their entire API takes only weakly typed objects :-)
MvcContrib Grid is much better.