积极答复者
Asp.net Dynamic Data如何通过编程给数据库表的通用字段赋值?

问题
-
默认情况下,Asp.net Dynamic Data创建的网站中,所有的数据操作都是通过用户在UI界面上输入后,由Asp.net Dynamic Data自动更新到数据库中!
请问:
在我的系统数据库中,每个表都有两个通用且非空的字段(ModifiedDate、Modifier),在通过Asp.net Dynamic Data创建的网站中,我希望所有表的这两个字段都是通过编程赋值,而不是由用户通过UI输入,因为由用户输入时会输入非法值:
比如,我希望:
表.ModifiedDate = DateTime.Now;
表.Modifier =当前登录系统的用户的名称
- 已编辑 H. H. Pern 2013年9月26日 5:32
- 已更改类型 H. H. Pern 2013年9月26日 5:38
答案
-
通过 http://forums.asp.net/t/1639003.aspx 帖子,找到解决方案了:
- 已标记为答案 H. H. Pern 2013年9月27日 3:34
全部回复
-
设法在每次页面加载的时候试图通过赋值的方式编程编进去看看如何。
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report -
设法在每次页面加载的时候试图通过赋值的方式编程编进去看看如何。
不好意思,理解您的意思,但不知如何下手(不知如何获得要编程的实体),能具体给点思路吗?谢谢!
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report -
假设你的Dynamic Data字段是通过EntityFramework或者LINQ-TO-SQL生成的,建议你加特性、或者是通过前台(js或jQuery等方式)直接对某些文本框设置默认数值。
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report -
假设你的Dynamic Data字段是通过EntityFramework或者LINQ-TO-SQL生成的,建议你加特性、或者是通过前台(js或jQuery等方式)直接对某些文本框设置默认数值。
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report我用的是EF,如果通过特性批注默认值,那是不是只能指定固定的默认值?而我需要的ModifiedDate是动态的系统时间,Modifier是因登录人不同动态的;
至于通过js或JQuery实现,我研究一下
-
通过 http://forums.asp.net/t/1639003.aspx 帖子,找到解决方案了:
- 已标记为答案 H. H. Pern 2013年9月27日 3:34