views:

21

answers:

1

Hi,

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 all 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?

A: 

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.

Chaitanya