'Declaration Public Event LocateDataSource As LocateDataSourceEventHandler
public event LocateDataSourceEventHandler LocateDataSource
Event Data
The event handler receives an argument of type LocateDataSourceEventArgs containing data related to this event. The following LocateDataSourceEventArgs properties provide information specific to this event.
Property | Description |
---|---|
Data | The data returned by the event handler. |
DataSet | Gets the report's GrapeCity.ActiveReports.PageReportModel.IDataSet object to locate data for. |
Parameters | Gets the Parameters collection specified for a given report instance. |
Report | Gets the Report that is trying to locate the data set. |
Remarks
This event is triggered when the report requires a data source that has not been predefined or needs to be resolved at runtime. It allows for the dynamic provision of data sources based on the report's requirements or user input.
Event handlers can use this opportunity to present data source selection dialogs, perform custom data source configuration, or apply logic to determine the appropriate data source for the current context.
Example
Utilize the specified event to supply data necessary for the preview functionality of page reports. This ensures that the report previews are populated with the latest data.
designer.LocateDataSource += (sender, args) => { var dataSourceName = args.DataSet.Query.DataSourceName; var dataSource = ((PageReport)designer.Report).Report.DataSources.First(x => x.Name == dataSourceName); if(dataSource.ConnectionProperties.DataProvider == "OBJECT") { args.Data = new[] { new { CustomerName = "Gc Inc." } }; } };
See Also