i have created a report dynamically in asp.net web form
based on user selection i add columns and i'm going to bound my data to selected columns using data band
i assign created report in page_load event to StiWebViewer , in first view it work's fine , but when i press next page button it
will be empty , even when i press prev page , the data of first page have losted too.
this is the same when i want to print report.
I have found when the report go to next page , if i refresh the page it's data will bound
I put my code here , please help me to find a solution.
i am thankful in advance
Code: Select all
DataTable dt = GetDataTableFromDGV(AFIs, ArrayTitle, ArrayEnTitle, ArrayOrder, ArrayChecked); // here i fetch my dt data
bool chkRotate = false;
foreach (DataColumn dc in dt.Columns)
{
dc.ColumnName = Stimulsoft.Report.CodeDom.StiCodeDomSerializator.ReplaceSymbols(dc.ColumnName);//ReplaceSpaceWithUnderline(dc.ColumnName);
}
DataView dataView = dt.DefaultView;
StiReport report = new StiReport();
report.ScriptLanguage = StiReportLanguageType.CSharp;
report.RegData("view", dataView);
report.Dictionary.Synchronize();
StiPage page = report.Pages.Items[0];
if (Landscape)
page.Orientation = StiPageOrientation.Landscape;
//
Double pos = 0;
//Double columnWidth = StiAlignValue.AlignToMinGrid(page.Width / dataView.Table.Columns.Count, 0.1, true);
Double columnWidth = StiAlignValue.AlignToMinGrid(page.Width / dt.Columns.Count, 0.1, true);
int nameIndex = 1;
Double CalculatedWidth = 0.0f;
//================================== overlap disharmonic lines ===================================
//for (int i = dataView.Table.Columns.Count - 1; i != -1; i--)
//{
// if (!chkAutoSize.Checked)
// {
// columnWidth = StiAlignValue.AlignToMinGrid((Convert.ToDouble(ColumnWidths[i]) / Convert.ToDouble(100)), 0.1, true);
// CalculatedWidth += columnWidth;//(Convert.ToDouble(ColumnWidths[i]) / Convert.ToDouble(100));
// }
//}
if (CalculatedWidth > (page.Width - 0.2))
{
page.Orientation = StiPageOrientation.Landscape;
}
else
{
if (!Landscape)
page.Orientation = StiPageOrientation.Portrait;
}
//creating ReportTitleBand ****************************
StiReportTitleBand rt = new StiReportTitleBand();
rt.Height = 1.5f;
rt.Name = "ReportTitleBand";
StiText st = new StiText(new RectangleD(0, 0, page.Width, 1f));
st.Text.Value = ReportTitle;
st.HorAlignment = StiTextHorAlignment.Center;
st.Name = "TitleText1";
st.Font = new Font("B Mitra", 16f);
rt.Components.Add(st);
page.Components.Add(rt);
//creating HeaderBand *******************************
StiHeaderBand headerBand = new StiHeaderBand();
if (chkRotate)
headerBand.Height = 0.9f;
else
headerBand.Height = 0.5f;
headerBand.Name = "HeaderBand";
page.Components.Add(headerBand);
//creating Dataaband ***********************************
StiDataBand dataBand = new StiDataBand();
dataBand.DataSourceName = "view" + dataView.Table.TableName;
dataBand.Height = 0.5f;
dataBand.Name = "DataBand";
dataBand.CanBreak = true;//Added 11 20 2014
page.Components.Add(dataBand);
pos = (page.Width - (columnWidth * Convert.ToDouble(dataView.Table.Columns.Count))) / Convert.ToDouble(2);
for (int i = dataView.Table.Columns.Count - 1; i != -1; i--)
{
DataColumn column = dataView.Table.Columns[i];
//creating Column Text
Double headerHeight = 0.5f;
if (chkRotate)
headerHeight = 0.9f;
StiText headerText = new StiText(new RectangleD(pos, 0, columnWidth, headerHeight));
headerText.Text.Value = Stimulsoft.Report.CodeDom.StiCodeDomSerializator.ReplaceSymbols(column.Caption).Replace("_", " ");
if (chkRotate)
headerText.Angle = 90;
headerText.HorAlignment = StiTextHorAlignment.Center;
headerText.VertAlignment = StiVertAlignment.Center;
headerText.Name = "HeaderText" + nameIndex.ToString();
headerText.Brush = new StiSolidBrush(Color.LightGreen);
headerText.Border.Side = StiBorderSides.All;
headerBand.Components.Add(headerText);
headerText.Font = new Font("B Nazanin", 11.0f);
StiText dataText = new StiText(new RectangleD(pos, 0, columnWidth, 0.5f));
dataText.Text.Value = "{view" + dataView.Table.TableName + "." + Stimulsoft.Report.CodeDom.StiCodeDomSerializator.ReplaceSymbols(column.ColumnName) + "}";
dataText.Name = "DataText" + nameIndex.ToString();
dataText.HorAlignment = StiTextHorAlignment.Center;
dataText.VertAlignment = StiVertAlignment.Center;
dataText.Border.Side = StiBorderSides.All;
dataText.Font = new Font("B Nazanin", 11.0f);
//Add highlight
if (true)
{
StiCondition condition = new StiCondition();
condition.BackColor = Color.CornflowerBlue;
condition.TextColor = Color.Black;
condition.Expression = "(Line & 1) == 1";
condition.Font = new Font("B Nazanin", 11.0f);
condition.Item = StiFilterItem.Expression;
dataText.Conditions.Add(condition);
}
dataBand.Components.Add(dataText);
pos += columnWidth;
nameIndex++;
}
report.Render(true);
StiWebViewer1.Report = report;