Data Controllers / Fields / Items Style

  User Id Lookup

Table of Contents
Data Controllers / Fields / Items StylePrint||
User Id Lookup

ASP.NET Membership offers a prefabricated registry of users and roles. There are situations in which the membership User ID needs to be referenced in the database. You can reference a User ID with the User Id Lookup items style.

Create an Owner field 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 Orders table in Northwind database.

Add a column with the following properties:

Column Name Data Type Allow Nulls
OwnerId nvarchar(50) True

Save the table design modifications.

Note that the data type of the field may be configured as uniqueidentifier if you are working with SQL Server. If your database engine is MySQL, then int type can be used instead.

Start Code On Time web application generator. Click on the project name, and refresh the Orders data controller.

Refresh the Orders controller.

Press Generate to regenerate the web application. When it opens in a browser window, navigate to Orders page and edit a record. The OwnerId field is just a simple text box. It needs to be converted into a User Id Lookup.

The OwnerId field is a simple text box.

Start the Project Designer. Switch to the Controllers tab, and double-click on Orders/ Fields / OwnerId node.

OwnerId field in the Orders controller in Code On Time Project Explorer.

Give this field the following properties:

Property Value
Label Owner
Items Style User ID Lookup

Press OK to save the field. On the toolbar, press Browse, and wait for the application to load.

Navigate to the Orders page, and edit a record. The Owner field will now be a lookup.

OwnerId field is now a User Id Lookup.

Click on the lookup link, and it will show a list of users.

User Id Lookup displaying a list of users.

When you select a user, the User Id will be inserted into the field.

Owner field displaying the User Id.