在asp.net mvc的动态设置显示名称标注数据 [英] setting displayname data annotation dynamically in asp.net mvc

查看:566
本文介绍了在asp.net mvc的动态设置显示名称标注数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库表具有以下字段

I have a database table with the following fields

item_key,
ITEM_VALUE,
显示名称,
uihint

item_key, item_value, display_name, uihint

我希望能够在displaytemplate使用,并且也显示名称数据库表来指定。

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) %>

该UIHint工作,但我不能工作了设置显示名称动态,上面code是生产像

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

item_value TEXTBOX

ITEM_VALUE TEXTBOX

item_value TEXTBOX

在哪里我不想被正在从DISPLAY_NAME场拉item_values​​称号。

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

是否有可能与数据的注解做到这一点?一直在寻找的<一个href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displayattribute%28v=VS.95%29.aspx\" rel=\"nofollow\">http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displayattribute%28v=VS.95%29.aspx和搜索周围,但没有设法找到的我是什么什么例子后

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

推荐答案

您必须实现您的cusotm ModelMetaDataProvider做到这一点。此链接应该让你开始:

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

<一个href=\"http://dotnetslackers.com/articles/aspnet/Customizing-ASP-NET-MVC-2-Metadata-and-Validation.aspx\" rel=\"nofollow\">http://dotnetslackers.com/articles/aspnet/Customizing-ASP-NET-MVC-2-Metadata-and-Validation.aspx

这篇关于在asp.net mvc的动态设置显示名称标注数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆