Update data source reference in report Definition
The report definition includes the dataset elements that define the data source structure used by the report. The dataset element is added to the report definition during the report design process. Each time you drag a specific field to the data area or text box in the report, a new element is added.
If you want to copy a report definition file between projects that contain different data sources or modify a dataset used in a project, you must update the report definition. If you subsequently modify the actual dataset in the project by deleting or renaming fields or tables, the report definition will no longer contain valid references. To update the report definition, use the "Data Source" dialog box, as described in the following steps.
How to update references in a report Definition
-
Open the client report definition (. rdlc) file in graphic design mode.
-
Select "Data Source" from the "Report" menu ". The "Report data source" dialog box is displayed. You can use the following options:
-
To add a new dataset to the report definition, select the "project" data source and click "add to report ". In most cases, this option is not necessary. When you drag a field to the report layout, the project data source is automatically added to the report definition.
-
To delete an existing dataset reference from the report definition, select a dataset and click Delete ".
-
If you rename a dataset in a project, you can use the "report data source" dialog box to update the dataset name in the report definition. Click the rename button to set the dataset name in overwrite mode, and then type a new name.
-
Click "Refresh all" to update the report definition file with the changed content.
Rebind the data source to the reportviewer Control
The reportviewer control requires data binding to access the application at runtime.ProgramData source. Creating data binding for controls is performed when you select the client report definition (. rdlc) file.
If you modify the report definition bound to a control, you must re-bind the data source after the control is bound to a form or webpage, or add a new dataset to the report. In all these cases, the binding will expire. You can use the "rebind data source" task on the "reportviewer task" Smart Tag Panel to update the application.CodeData Binding in.
| Note: |
|
Not all changes to the report definition must be rebound to the data source. For example, changes such as resetting items, formatting items, or reusing the same data binding field in multiple data regions do not invalidate the existing data binding. Similarly, if the modification is not part of the data source used in the report, you do not need to update the binding. |
How to rebind data sources
-
Open a form or webpage containing the reportviewer control.
-
On the "reportviewer task" Smart Tag panel, click "rebind data source ". You can check the code of the form or page to confirm the changes.
Select a data source for the reportviewer Control
When converting a Server Report definition (. RDL) file to a client report definition (. rdlc) file, make sure that your application contains the data binding code of the reportviewer control. The data binding code is automatically generated when the. rdlc file is created using a report template. However, if you create the. rdlc file in some other way, the data binding code is lost. To add data binding code, use "reportviewer task" to intelligently tag the "Select data source" task on the panel. For more information about the definition of a conversion report, seeConvert RDL files and rdlc files.
How to add data source binding
-
Open a form or webpage containing the reportviewer control.
-
On the "reportviewer task" Smart Tag panel, click "Select data source ". You can check the code of the form or page to confirm the changes.
This article is transferred from: http://msdn.microsoft.com/zh-cn/library/ms252085 (vs.80). aspx