This is a migrated thread and some comments may be shown as answers.

Pass parameter to chart from aspx?

2 Answers 101 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
engin
Top achievements
Rank 1
engin asked on 01 Jun 2011, 11:38 AM
Hello 

I need to create (reporting) chart on aspx codebehind programmaticaly. I couldnt find out how to do it .  All  programmaticaly examples which i ve seen were creatiıng programmaticaly chart on report.cs instead of aspx.cs.

Im waitin for ur helps.

Thanks..


 

2 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 01 Jun 2011, 03:45 PM
Hi engin,

To create programmatically report, you need Telerik.Reporting.Report and Telerik.Reporting.DetailSection instance. Check out the following code snippet:

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        Telerik.Reporting.Chart progchart = new Telerik.Reporting.Chart();
        progchart.BitmapResolution = 96F;
        progchart.ImageFormat = System.Drawing.Imaging.ImageFormat.Emf;
        progchart.Location = new Telerik.Reporting.Drawing.PointU(new Telerik.Reporting.Drawing.Unit(0.3), Telerik.Reporting.Drawing.Unit.Cm(0.3));
        progchart.Name = "progchart1";
        progchart.PlotArea.EmptySeriesMessage.Appearance.Visible = true;
        progchart.PlotArea.EmptySeriesMessage.Visible = true;
        progchart.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Cm(9.6), Telerik.Reporting.Drawing.Unit.Cm(6.1));
 
        var report = new Telerik.Reporting.Report();
        var detail = new Telerik.Reporting.DetailSection();
        report.Items.Add(detail);
        detail.Items.Add(progchart);
 
        this.ReportViewer1.Report = report;
    }
}

However this is not the intended way to utilize Telerik Reporting because the reports that you can create with Telerik Reporting can have complex layout consisting of multiple report items, aggregates, expressions, groups and etc. Thus when possible our suggestion is to use our comprehensive Report Designer that simplifies the report creation task. 

Kind regards,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
engin
Top achievements
Rank 1
answered on 02 Jun 2011, 02:47 PM
Hi Peter,

Yes It works. I should have used 'var ' thanks a lot.  I needed to pass paramaters to report with asp.net controls. Thats why i asked 

by the way thank you..
Tags
General Discussions
Asked by
engin
Top achievements
Rank 1
Answers by
Peter
Telerik team
engin
Top achievements
Rank 1
Share this question
or