Data fields can be configured as a User Name Lookup to allow selection and insertion from the user names registered in the ASP.NET membership tables.
First, add an Owner column in the Orders table.
Start SQL Server Management Studio. In the Object Explorer, right-click on Databases / Northwind / Tables / dbo.Orders node, and select Design option.
Add the following column:
Column Name | Data Type | Allow Nulls |
OwnerName | nvarchar(50) | True |
Save the table design. Switch to Code On Time web application generator, and refresh the Orders controller.
Generate the application. Navigate to the Orders page, and select a record. The Owner Name field will just be a simple text box. Let’s convert this text box into a User Name Lookup.
Start the Project Designer. In the Project Explorer, switch to the Controllers tab. Double-click on Orders / Fields / OwnerName field node.
Change the Items Style property:
Property | New Value |
Items Style | User Name Lookup |
Press OK to save the field. On the toolbar, click Browse.
Navigate to the Orders page and edit a record. The Owner Name field will now be a lookup.
When you activate the lookup, a list of users will be displayed.
Select a user, and the user name will be inserted into the field.