problem with render Dynamically Created report

Stimulsoft Reports.WEB discussion
Post Reply
zerocool
Posts: 3
Joined: Mon Mar 09, 2015 10:47 am

problem with render Dynamically Created report

Post by zerocool »

Hello ,
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;
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: problem with render Dynamically Created report

Post by HighAley »

Hello.

What event do you use?
Please, send us full code of the aspx page and cs-file.

Thank you.
zerocool
Posts: 3
Joined: Mon Mar 09, 2015 10:47 am

Re: problem with render Dynamically Created report

Post by zerocool »

Dear Aleksey
Due to my compani's security measurements i cant send cs file,
I have put my C# codes in a method named ShowReport() which i mention above
then i call ShowReport() in page_load , there all my cs code behind.

and here is my aspx page code

Code: Select all

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelfReservedFoodReport.aspx.cs"
    Inherits="MadaktoTS.UI.Pages.Reports.Attendance.SelfReservedFoodReport" %>

<%@ Register Assembly="Stimulsoft.Report.Web, Version=2013.2.1612.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxx"
    Namespace="Stimulsoft.Report.Web" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <cc1:StiWebReport ID="StiWebReport1" runat="server" />
        <br />
        <cc1:StiWebViewer ID="StiWebViewer1" runat="server" OnLoad="StiWebViewer1_Load" />
    </div>
    </form>
</body>
</html>
zerocool
Posts: 3
Joined: Mon Mar 09, 2015 10:47 am

Re: problem with render Dynamically Created report

Post by zerocool »

I solve this problem by make my report static
and omit report.render(true);

the only problem that i face is whether my column number which i generate them dynamically exceed a4 paper what should i do?
moreover how can i make column width fit to their content?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: problem with render Dynamically Created report

Post by HighAley »

Hello.

Please, send us a screen-shot of the problem to support@stimulsoft.com

Thank you.
Post Reply