2015-08-14 52 views
-1

我想添加一個手動創建的圖表到一個佔位符,但是當我看到輸出所有我得到的是一個空白..我從數據集中獲取數據數據表是數據集中的最後一個表。我只有兩個colums「工業」和「industryTheta」的任何幫助非常感謝。我不知道這裏有什麼錯誤添加圖表控件到佔位符ASP.net VB

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) 

回答

0

當你在頁面生命週期中調用你的函數時,最有可能你的問題是。請參閱this信息以瞭解更多信息。

爲了解決asp.net中的動態控制問題,請參考this瞭解更多關於動態控件的信息。