0

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

1
  • Why don't you just place simple label with display name or create template for whole pageField type? Commented Jul 12, 2010 at 13:29

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

I know this was forever ago, but the link no longer works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.