Page 1 of 1

trouble removing data sources

Posted: Wed May 04, 2011 2:44 pm
by miguel
Hi I have a report with 2 data sources, and creating a new blank report, I need to delete existing data sources

for this command to call the method sig. when I select new report

void StiDesigner_CreatedReport(object sender, EventArgs e)
{
StiDataSourcesCollection sCollect = new StiDataSourcesCollection(new StiDictionary());
foreach (StiDataSource source in report.Dictionary.DataSources)
{
if (!source.Name.Contains("reporte"))
sCollect.Add(source);
}
report.Dictionary.DataSources = sCollect;
}

but I only open a blank layout but the sources did not delete them

I hope I can explain how pls

trouble removing data sources

Posted: Fri May 06, 2011 6:38 am
by Alex K.
Hello,

Please try to use the following code:

Code: Select all

void GlobalEvents_CreatingReportInDesigner(object sender, StiCreatingObjectEventArgs e)
{
    StiReport report = ((StiDesignerControl)sender).Report;
    StiDataSourcesCollection sCollect = new StiDataSourcesCollection(new StiDictionary());
    foreach (StiDataSource source in report.Dictionary.DataSources)
    {
        if (!source.Name.Contains("Categories"))
            sCollect.Add(source);
    }
    report.Dictionary.DataSources = sCollect;

    e.Processed = false;
}
Thank you.