views:

70

answers:

1

I have a database table with the following fields

item_key, item_value, display_name, uihint

I want to be able to specify in the database table which displaytemplate to use and also the displayname.

<%= Html.EditorFor(p=>pageField.item_value, pageField.uihint) %>

The UIHint is working, but I can't work out a way of setting the displayname dynamically, the above code is producing something like

item_value TEXTBOX

item_value TEXTBOX

item_value TEXTBOX

Where I want the item_values titles to be being pulled from the display_name field.

Is it possible to do this with data annotations? Have been looking at the http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displayattribute%28v=VS.95%29.aspx and searching around, but haven't managed to find any examples of what I am after

A: 

You have to implement your cusotm ModelMetaDataProvider to do that. This link should get you started:

http://dotnetslackers.com/articles/aspnet/Customizing-ASP-NET-MVC-2-Metadata-and-Validation.aspx

Andreas Rathmayr