0

I'm trying to show a model in a WebGrid which has one column with a custom class. Without using the "format:" parameter to customize the column in the WebGrid, can I add something to my custom class (something like a default cast= to show a custom text instead of the full class name in the WebGrid? I tried implicit/explicit conversion operators to string or HtmlString without success... Thanks in advance!

2 Answers2

0

Without using the "format:" parameter to customize the column in the WebGrid, can I add something to my custom class (something like a default cast= to show a custom text instead of the full class name in the WebGrid?

AFAIK you should use a custom format: in the corresponding column.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • Yes, I know too... but... I need to remember to use the "format" on each view, while if I add some generic cast to the class, it must be added only one time... much better if I need only text. Also: it will enable sorting for that column... with only using the format, won't be sorted at all. – Marc Baye May 10 '12 at 10:37
  • I agree with you. You may checkout MVCContrib.Grid or Telerik MVC Grid which have more functionality than the built-in WebGrid. – Darin Dimitrov May 10 '12 at 11:16
0

I found it, easier than I expect: override ToString()!!!