I want to set a new class for this part of my code, but it doesn't work correctly
@Html.DisplayFor(model => model.melk.Code, new { @class = "myClass" } )
Can anyone tell me where am I wrong?
The DisplayExtensions.DisplayFor overload that you are using will find the DisplayTemplate based on the type of the model.melk.Code and the last parameter (anonymous object new { @class = "myClass" } will be passed to the template's ViewData. You have to use that ViewData in the corresponding template in order for it to work.
<div class="@(ViewData["class"])"...