Skip to main content

Display the User Name in a Report

This tutorial demonstrates how to insert the current user name in a report using the XRPageInfo control.

HowTo - InsertUserName_3

Do the following to insert the user name into a report:

  1. To create a table report in this tutorial, start with a report that is bound to the “Products” table of the sample Northwind database. To learn more about binding a report to a data source, see Provide Data to Reports.
  2. In the Visual Studio Report Designer, switch to the Field List, select the ProductName and UnitPrice fields, and drag-and-drop them onto the report’s Detail band.

    HowTo - FilterDataReportLevel_0

  3. Typically, the user name is displayed within the ReportHeaderBand. To add it to the report, right click anywhere on the report’s surface. In the invoked menu, point to Insert Band and click ReportHeader.

    Shared_BandsAddReportHeader

  4. Drop the XRPageInfo control from the DX.23.2: Report Controls Toolbox tab onto the ReportHeader band.

    HowTo - InsertUserName_0

  5. Set the control’s XRPageInfo.PageInfo property to UserName (e.g. using its smart tag).

    HowTo - InsertUserName_1

  6. Next, to apply a format string to the control’s contents, type Current User: {0} into its Format property.

    HowTo - InsertUserName_2

See Also