开发者

Restricting the values of nvarchar column using dynamic data entities

开发者 https://www.devze.com 2023-01-13 18:28 出处:网络
I am using ASP.NET Dynamic Data Entities project to generate a web application for my database. I was wondering what is the easiest way to restrict the allowed values for a column without changing the

I am using ASP.NET Dynamic Data Entities project to generate a web application for my database. I was wondering what is the easiest way to restrict the allowed values for a column without changing the database structure to make that column a foreign key or modifying the database in any way.

For example. I have a table called Assets which has an nvarchar(50) column of TypeOfAsset. I want to restrict the type of asset to "Printer", "Desktop" or "Laptop" for example. I would like al开发者_StackOverflow中文版l the search and create templates to automatically use Dropdown lists for this column rather than a text field.

Would I have to create custom templates and use the UIHint attirbute? Is there some other attribute I can use in the metadata? or is there a way to restrict the values in LinqToSql, so that as far as Dynamic Data Entities are concerned, it naturally uses Dropdownlists?


Found the answer here. http://csharpbits.notaclue.net/2009/07/dynamic-data-custom-field-template.html

Basically creating a custom attribute and a custom field template. The attribute specifies the restricted values to display and the field template has a dropdownlist that will be populated with the comma delimited values specified in the attribute.

0

精彩评论

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