将图表控件添加到占位符ASP.net VB

时间:2015-08-14 18:58:45

标签: asp.net vb.net

我正在尝试将手动创建的图表添加到占位符,但是当我查看输出时,我得到的是一个空白..我从数据集数据表中获取数据,这是数据集中的最后一个表。我只有两个专栏“工业”和“IndustryTheta”任何帮助非常感谢。我不确定这里有什么问题

 Dim chrt As New Chart
            chrt.ID = "dynChart"
            chrt.Height = Unit.Pixel(1000)
            chrt.Width = Unit.Pixel(1000)
            chrt.BackImageWrapMode = ChartImageWrapMode.Scaled
            chrt.BorderlineColor = Color.Black
            chrt.ImageLocation = "~/TempImages/ChartPic_#SEQ(300,3)"
            chrt.BackGradientStyle = GradientStyle.None

            Dim ca As New ChartArea
            ca.Name = "IndustryTheta"
            ca.AlignmentOrientation = AreaAlignmentOrientations.All
            ca.AlignmentStyle = AreaAlignmentStyles.All
            ca.Area3DStyle.Enable3D = True
            ca.Area3DStyle.LightStyle = LightStyle.Realistic
            ca.Area3DStyle.Inclination = 30
            ca.BackHatchStyle = ChartHatchStyle.None

            chrt.ChartAreas.Add(ca)

            Dim sers As New Series
            sers.Name = "IndustryName"
            sers.ChartType = SeriesChartType.Pie
            sers.Label = "#VALX, #PERCENT"
            sers.LabelAngle = 90
            sers.IsXValueIndexed = True
            sers.IsValueShownAsLabel = True
            sers.XAxisType = AxisType.Primary
            sers.YAxisType = AxisType.Primary
            sers.YValuesPerPoint = 1
            sers.XValueMember = "Industry"
            sers.YValueMembers = "IndustryTheta"

            chrt.Series.Add(sers)

            For Each dr As DataRow In table.Rows
                Dim p As New DataPoint
                p.SetValueY(Convert.ToInt32(dr.Item("IndustryTheta")))
                p.AxisLabel = dr.Item("Industry")
                sers.Points.Add(p)
            Next

            chrt.DataBind()

            dynamicGrids.Controls.Add(chrt)

1 个答案:

答案 0 :(得分:0)

当您在页面生命周期中调用函数时,很可能出现问题。请参阅this信息以了解有关它的更多信息。

为了解决asp.net中的动态控件,请参阅this以获取有关动态控件的更多信息。