# GrapeCity.ActiveReports.Design.Designer.LocateDataSource

## Content

<div class="doc-site-dotnet-api-container">




<h1 id="GrapeCity_ActiveReports_Design_Designer_LocateDataSource" data-uid="GrapeCity.ActiveReports.Design.Designer.LocateDataSource" class="text-break">LocateDataSource Event
</h1>
<div class="markdown level0 summary"><p>Occurs when a data source is needed for the report. This event enables dynamic data source resolution.</p>
</div>
<div class="markdown level0 conceptual"></div>
<h6><strong>Namespace</strong>: <a class="xref" href="GrapeCity.ActiveReports.Design.html">GrapeCity.ActiveReports.Design</a></h6>
<h6><strong>Assembly</strong>: MESCIUS.ActiveReports.Design.Win.dll</h6>
<h5 id="GrapeCity_ActiveReports_Design_Designer_LocateDataSource_syntax">Syntax</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public event LocateDataSourceEventHandler LocateDataSource</code></pre>
</div>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.LocateDataSourceEventHandler.html">LocateDataSourceEventHandler</a></td>
      <td>Occurs when a data source is needed for the report. This event enables dynamic data source resolution.</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Design_Designer_LocateDataSource_remarks"><strong>Remarks</strong></h5>
<div class="markdown level0 remarks"><p>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.</p>
<p>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.</p>
</div>
<h5 id="GrapeCity_ActiveReports_Design_Designer_LocateDataSource_examples"><strong>Examples</strong></h5>
<p>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.</p>
<pre><code class="lang-csharp">designer.LocateDataSource += (sender, args) =&gt; {
	var dataSourceName = args.DataSet.Query.DataSourceName;
	var dataSource = ((PageReport)designer.Report).Report.DataSources.First(x =&gt; x.Name == dataSourceName);
	if(dataSource.ConnectionProperties.DataProvider == "OBJECT")
	{
	    args.Data = new[] { new { CustomerName = "Gc Inc." } };
	}
};</code></pre>

</div>
