Hi Chris Ward,
Indeed your observation is correct -- the actual databinding occurs after the NeedDataSource event so no chart series will be generated here.
Generally there are only two possible places where you can set the XAxis.LabelStep property effectively -- the ItemDataBinding and the NeedDataSource events -- but both of them occur early in the lifecycle and the chart data is not retrieved yet for you to use it in the calculation of the label step.
There are two possible options -- you can build the chart series manually in the NeedDataSource (without SqlDataSource control), or you can keep the SqlDataSource implementation but in this case you would need to perform a second SELECT command to your database (in the ItemDataBinding / NeedDataSource event handlers) in order to retrieve the data item count like this:
sender, EventArgs e)
System.Web.UI.WebControls.SqlDataSource sql =
sql.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings[
"SELECT COUNT(UnitsInStock) FROM Products"
var result = sql.Select(
var itemCount = (result
chart1.PlotArea.XAxis.LabelStep = (
)itemCount / 30;
Note that you need to use the stock System.Web.UI.WebControls.SqlDataSource control (and not Telerik.Reporting.SqlDataSource) as you need to call the Select(...) method manually.
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat
for a walk through all the exciting stuff we ship with the new release!