Eg:
TABLEAxxx <- generic
TABLEAcompany1
TABLEAcompany2
...
I need to replace the "xxx" string in every datasource because the report/dashboard is generic and could not be bound to a specific table name, as another customer usually has different companies in the DB.
I came up with this code
Code: Select all
protected void StiWebViewer1_GetReport(object sender, EventArgs e)
{
Stimulsoft.Report.Dashboard.StiCacheCleaner.Clean();
// Sostituisco i token "xxx" delle tabelle generiche con il codice ditta
int index;
StiReport myReport;
StiSqlSource mySqlSource;
myReport = StiWebViewer1.Report;
for(index=0;index < myReport.Dictionary.DataSources.Count; index++ )
{
mySqlSource = (StiSqlSource)myReport.Dictionary.DataSources[index];
mySqlSource.SqlCommand = mySqlSource.SqlCommand.Replace("xxx", Session["sCODAZI"].ToString());
}
}
In the designer it's a bit more complicate, since I can't just replace the "xxx" to show the preview, it will be saved!
Is it possible to replace it temporarily only when previewing in the designer without changing the actual datasource?
The only alternative is to remember to change back every occurrence to "xxx" just before saving… but it's really risky
EDIT: I just found about onpreviewreport event which can be used to manipulate the datasources in the same way without influencing the designer!
This is a wonderful tool, thank you