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

Simple Report

1 Answer 135 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Azees
Top achievements
Rank 1
Azees asked on 04 Jun 2009, 01:57 PM

Hi

     I am new in telerik reporting I create simple report for our compnay employee details

1)  how to use telerik reporting in web application

     i got one code from telerik site but  i cant create sqldatasource in that class ( i think its only support in web)

using System;
using Telerik.Reporting.Chart;

  
public partial class Report1 : Report
   {
       
public Report1()
       {
           
/// <summary>
           
/// Required for telerik Reporting designer support
           
/// </summary>
           
InitializeComponent();

           
// create a datasource
           
SqlDataSource sqlDataSource = new SqlDataSource();
           sqlDataSource.ID =
"myDataSource";
           sqlDataSource.ConnectionString =
           ConfigurationManager.ConnectionStrings[
"NorthwindConnectionString"].ConnectionString;
           sqlDataSource.SelectCommand =
           
"SELECT CategoryName, SUM(ProductSales) AS TotalSales FROM [Product Sales for 1997] GROUP BY CategoryName";
           
//setup chart
           
BuildChart();
       }
       
private void BuildChart()
       {
           
// assign it to Chart  
           
Chart1.DataSourceID = "myDataSource";
           
// Set the column for data and data labels:
           
// Each bar will show "TotalSales", each label along
           
// X-axis will show "CategoryName.
           
Chart1.Series[0].DataYColumn = "TotalSales";
           Chart1.PlotArea.XAxis.DataLabelsColumn =
"CategoryName";
           
// assign appearance related properties
           
Chart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 300;
           Chart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Color =
           System.Drawing.Color.BlueViolet;
           Chart1.PlotArea.Appearance.Dimensions.Margins.Bottom =
           Telerik.Reporting.Charting.Styles.Unit.Percentage(30);

       }
   }




2)  I have write code in  following event.But i cant give data source for that chart1

private

 

void chart1_NeedDataSource(object sender, EventArgs e)

 

{

 

}

3) I trying following code this code also throwing error like

An error has occured while processing Chart 'chart1':
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

 

private void chart1_NeedDataSource(object sender, EventArgs e)

 

{

Telerik.Reporting.Processing.

 

Chart chart = sender as Telerik.Reporting.Processing.Chart;

 

 

 

string command = "Select EmpId,Salary from tblemp";

 

 

 

SqlDataAdapter sqldataAdapter = new SqlDataAdapter(command, "Data Source=SVNSERVER;Initial Catalog=HR;User ID=sa;Password=Ava_123@");

 

 

 

DataSet ds = new DataSet();

 

sqldataAdapter.Fill(ds);

 

 

DataView dv = ds.Tables[0].DefaultView;

 

chart.DataSource = dv;

 

 

//this.DataSource = dv;

 

 

chart1.Series[0].PlotArea.XAxis.DataLabelsColumn =

"EmpName";

 

chart1.Series[0].PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 330;

 

 

 

 

}

 


3) Finally i want  how to bind values from database to chart



Regards,

Friend

1 Answer, 1 is accepted

Sort by
0
Ivan
Telerik team
answered on 08 Jun 2009, 12:51 PM
Hello Azees,

Currently Telerik Reporting does not support direct data binding to a SqlDataSource. While we have future plans to improve the data binding support of our product, you can check the current list of supported data sources in the online documentation. You can also visit our online demos for more detailed examples on data binding, especially the Sales Dashboard sample report, which illustrates how you can bind the Chart report item to a database.

If you have more questions regarding data binding, please, do not hesitate to ask.

All the best,

the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
Azees
Top achievements
Rank 1
Answers by
Ivan
Telerik team
Share this question
or