Adding Table Data Regions (Visual Studio Report Designer)
A table data region is a data-bound report item that contains multi-column, multi-instance data on a report. A table has a static set of columns and a variable number of rows depending on the data in the dataset. Tables can contain as many columns as you want.
A table data region is composed of multiple parts. At a minimum, it includes detail rows. You can also specify table headers, table footers, group headers, and group footers. You can nest other data-bound report items within a table data region, including another table.
Working with Table Data Regions
When designing a report, you add a table data region by selecting Table from the Toolbox and dragging it onto the report. You can add a table data region to a new blank report or an existing report. After the table data region is on the report, you can add columns and rows to it.
To work with a table data region, you use handles that are located on the columns, rows, and table Handles are gray boxes that appear above and next to the table when it is selected. The handles that run across the top of the table are column handles. The handles that run down the side of the table are row handles. The handle where the column and row handles meet is the corner handle. You can perform most actions with columns, rows, and the table by right-clicking on column handles, row handles, or the corner handle, respectively. To select the table, click the corner handle.
How to Add, Move, and Delete a Table
To add a table
Open the client report definition (.rdlc) file in graphical design mode.
In the Toolbox, click Table.
Click the design surface of the report.
After the table is on the report, you can move it by pointing to the shaded border of the table and dragging it to a new location (click anywhere on an empty area on the table to cause the shaded border to appear). To delete a table, right-click any empty space within the table and press DELETE.
Each table data region is associated with a data source. If the report contains a single dataset, the table is automatically associated with that dataset when you place it on the report. If the report contains multiple datasets, you must associate the table with a specific dataset by dragging fields onto the table.
How to Insert Columns and Rows
You can add new columns to the table. You can also add rows. Note that each row contains a specific kind of data. A table can have only one Details row, but you can add new rows to create groups.
To insert a column, click the table so that column and row handles appear above and next to table. Right-click a column handle, and then click Insert Column to the Right or Insert Column to the Left.
To insert a row, right-click a row handle where you want to insert a row, and then click Insert Row Above or Insert Row Below. The type of row selected determines the type of row inserted. For example, if you select a group header or footer row, the type of row that will be inserted is another group header or footer.
How to Bind Data to a Table
After you add a table to the report layout, you add fields or expressions to the cells in the table.
To bind data to a table, drag a field from the Data Sources window onto a table cell. If you drag the field onto a cell in a table column that does not have a header (for example, the Details row), the name of the field automatically appears in the column header.
If the Data Sources window does not appear, in the Data menu, click Show Data Sources.
Each cell in the table contains a text box by default. You can change the type of item within the cell to another type (for example, change a text box in a cell to an image). Cells within the table can also span multiple columns.
Data in a table can be placed into groups and then sorted. For example, you might group products within product categories within departments and then sort the data in ascending order. For more information about grouping and sorting data, see Grouping Data in a Report (Visual Studio Report Designer) and Sorting Data in a Report (Visual Studio Report Designer).
How to Group Data in a Table
To add a group to a table
Click the table so that column and row handles appear above and next to the table.
Right-click the row handle where you want to insert the group and then click Insert Group.
The location of the new group row is determined by the row that is selected. Selecting a detail row places the new group just outside the detail row. Selecting an existing group row places the new group inside the selected group row.
On the General tab, do the following:
In Name, type the name of the group.
In Group on, type or select the expressions by which to group the data.
(Optional) In Document map label, type or select an expression to use as a document map label.
(Optional) If this group is a recursive hierarchy, for Parent group, type or select an expression to use as the recursive group parent.
(Optional) Click Page break at start or Page break at end to place a page break at the beginning or end of each group instance.
(Optional) Click Include group header or Include group footer to place a header or footer for the group in the table.
(Optional) Click Repeat group header or Repeat group footer to repeat the group header or footer on each page in which the table appears.
(Optional) On the Sorting tab, select or type expressions on which to sort the data within the group.
(Optional) On the Filters tab, select or type expressions by which to filter the data within the group.
(Optional) On the Visibility tab, select the visibility options for the item. For more information about visibility, see Adding Interactivity, Visibility, and Navigation to a Report (Visual Studio Report Designer).
(Optional) On the Data Output tab, select the data output options for the item.
Multiple contiguous cells within a table can be combined into a single cell. This is known as a column span or a cell merge. Cells can only be combined across columns. When you merge cells, only the data in the first cell is preserved. If data exists in other cells, the data is removed. Merged cells can be split into their original columns.
To merge cells, select the cells, right-click the selected cells, and then click Merge Cells. To split merged cells, right-click the merged cells, and then click Split Cells.
To add a subtotal to a table, add an aggregate expression to a cell in a group row. For example, if you have a table that is grouped by product category, product subcategory, and product, and you want to display a sum of sales by category and subcategory, you would place the expression
=Sum(Fields!Sales.Value) in the group header or footer rows for category and subcategory. Sum is an aggregate function. Reporting Services will calculate the sum of the values within the group and display the subtotal.