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

Chart Data Binding

1 Answer 53 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ankit Dwivedi
Top achievements
Rank 1
Ankit Dwivedi asked on 11 Jan 2010, 09:11 AM

I have a chart and table wizard both are depended on report parameter.
Table data is refreshing when i am selecting any other value from dropdown
but chart is not refreshing based on dropdown.

I have alredy check your product line sales demo but its not clear that
where I can pass the parameter for chart refreshing.

Private Sub chart1_NeedDataSource(ByVal sender As Object, ByVal e As
System.EventArgs) Handles chart1.NeedDataSource
Dim conn = New SqlConnection("Data Source=XXXXXX;Initial
Catalog=XXX;Persist Security Info=True;User ID=XXXXXXX;Password=XXXXXXXX")
Dim adp As SqlDataAdapter
adp = New SqlDataAdapter()
Dim scomm As New SqlCommand
Dim dst As New DataSet
scomm.CommandText = "SELECT presentpost, sum(CurrentSalary) as TotalSalary
from associate where activestatus='A' group by presentpost"
scomm.Connection = conn
adp.SelectCommand = scomm
Dim chart As Telerik.Reporting.Processing.Chart = TryCast(sender,
chart.DataSource = dst
chart1.PlotArea.XAxis.DataLabelsColumn = "TotalSalary"
End Sub

Please help me this is really most important part for my project.
we can decide to purchase this license.


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 11 Jan 2010, 05:30 PM
Hello Ankit,

If you review carefully the Product Line Sales demo report code behind you would notice that the chart data is filtered directly through its query e.g.:

string commandText = @"
SELECT TOP 10 C.LastName
    , C.FirstName
    , PC.Name
    Sales.SalesPerson AS SP
    INNER JOIN HumanResources.Employee AS E ON SP.SalesPersonID = E.EmployeeID
    INNER JOIN Production.ProductCategory AS PC ON PS.ProductCategoryID = PC.ProductCategoryID
    PS.Name IN (" + FormatParam((IList)this.ReportParameters["ProductSubcategory"].Value) + ") " +
    , C.FirstName
    , E.EmployeeID
    , PC.Name";

This is needed as the chart does not use the reporting data engine and that is the reason it cannot be bound through the report designer. As you can see from the above code, the ProductSubcategory report parameter value is used to filter the query used for binding the report.

the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
General Discussions
Asked by
Ankit Dwivedi
Top achievements
Rank 1
Answers by
Telerik team
Share this question