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.
![Design the Orders table in the Northwind database using SQL Server Management Studio. Design the Orders table in the Northwind database using SQL Server Management Studio.](/blog/2012/06/items-styleuser-name-lookup/image02.png)
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.
![Refresh the Orders controller. Refresh the Orders controller.](/blog/2012/06/items-styleuser-name-lookup/image04.png)
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.
![Owner Name field is currently a simple text box. Owner Name field is currently a simple text box.](/blog/2012/06/items-styleuser-name-lookup/image06.png)
Start the Project Designer. In the Project Explorer, switch to the Controllers tab. Double-click on Orders / Fields / OwnerName field node.
![OwnerName field in the Orders controller. OwnerName field in the Orders controller.](/blog/2012/06/items-styleuser-name-lookup/image08.png)
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.
![Owner Name field is now a User Name Lookup. Owner Name field is now a User Name Lookup.](/blog/2012/06/items-styleuser-name-lookup/image10.png)
When you activate the lookup, a list of users will be displayed.
![Activating a User Name Lookup will display a list of users. Activating a User Name Lookup will display a list of users.](/blog/2012/06/items-styleuser-name-lookup/image12.png)
Select a user, and the user name will be inserted into the field.
![Selecting a user from the lookup will insert the User Name into the field. Selecting a user from the lookup will insert the User Name into the field.](/blog/2012/06/items-styleuser-name-lookup/image14.png)