开发者

setting displayname data annotation dynamically in asp.net mvc

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开发者_StackOverflow'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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜