我有一个数据集,我如何使用跌破code。通过使用下面的原始code绑定radchart?
部分公共类Chart_Examples_Skinning_Bars_DefaultCS
继承System.Web.UI.Page
保护小组的Page_Load(发送者为对象,E作为EventArgs的)
如果不Page.IsPostBack然后
昏暗系列作为新ChartSeries中()
series.Type = ChartSeriesType.Bar
series.DataXColumn =与xValue
series.DataYColumn =y值
CapacityRadChart.Series.Add(系列)
CapacityRadChart.DataSource = Me.GetDataSource()
CapacityRadChart.DataBind()
结束如果
结束小组
专用功能了getDataSource()方式列表(共1类)
昏暗为r新的随机()
昏暗的来源方式列表(共1类)=新名单(共1类)
对于我作为整数= 0至399
昏暗的项目作为新的1级()
item.XValue = I
item.YValue = R。[下一页](0,100)
source.Add(项目)
下一个
返回源
端功能
末级
我做的这样,但它引发了以下错误:
列与COUNT的类型是不是数值
请你能提出适当的code?
昏暗DT作为数据表= ds.Tables.Item(0)
昏暗博士担任的DataRow
昏暗的ListData随着新名单(双)
昏暗的列表作为新的列表(中的DataRow)(DT [选择]())
对于每一个博士在dt.Rows
list.Add(dr.ToLis)
下一个
昏暗系列作为新ChartSeries中()
series.Type = ChartSeriesType.Bar
series.DataXColumn =CapacityDelay
series.DataYColumn =COUNT
BaselineRadChart.Clear()
BaselineRadChart.Series.Add(系列)
BaselineRadChart.DataSource =列表
BaselineRadChart.DataBind()
解决方案
如何创建在ds.Tables.Item一列(0)?你直接从数据库中绑定的数据表或手动创建数据表?
如果您手动创建它,那么你可能需要声明的数据类型的DataColumn的
昏暗DT作为数据表
dt.Columns.Add(CapacityDelay,System.Type.GetType(System.String))
dt.Columns.Add(计数,System.Type.GetType(System.Int32的))
I have a dataset, How can I use the below code to bind the radchart by using the below Original code?
Partial Public Class Chart_Examples_Skinning_Bars_DefaultCS
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs)
If Not Page.IsPostBack Then
Dim series As New ChartSeries()
series.Type = ChartSeriesType.Bar
series.DataXColumn = "XValue"
series.DataYColumn = "YValue"
CapacityRadChart.Series.Add(series)
CapacityRadChart.DataSource = Me.GetDataSource()
CapacityRadChart.DataBind()
End If
End Sub
Private Function GetDataSource() As List(Of Class1)
Dim r As New Random()
Dim source As List(Of Class1) = New List(Of Class1)
For i As Integer = 0 To 399
Dim item As New Class1()
item.XValue = i
item.YValue = r.[Next](0, 100)
source.Add(item)
Next
Return source
End Function
End Class
I'm doing it in this way, But it is throwing the following error:
the type of column with "COUNT" is not numeric".
Please could you suggest appropriate code?
Dim dt As DataTable = ds.Tables.Item(0)
Dim dr As DataRow
Dim listdata As new List(Of Double)
Dim list As New List(Of DataRow)(dt.[select]())
For Each dr In dt.Rows
list.Add(dr.ToLis)
Next
Dim series As New ChartSeries()
series.Type = ChartSeriesType.Bar
series.DataXColumn = "CapacityDelay"
series.DataYColumn = "COUNT"
BaselineRadChart.Clear()
BaselineRadChart.Series.Add(series)
BaselineRadChart.DataSource = list
BaselineRadChart.DataBind()
解决方案
How do you create a columns in ds.Tables.Item(0)? Do you bind the DataTable directly from database or create the DataTable manually?
If you create it manually, then you may need to declare the DataType for the DataColumn
Dim dt As DataTable
dt.Columns.Add("CapacityDelay", System.Type.GetType("System.String"))
dt.Columns.Add("Count", System.Type.GetType("System.Int32"))