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
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
3) Finally i want how to bind values from database to chart
Regards,
Friend
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