I need help getting a constaint line in a chart that is inside of a datalist control. When I try to use the CustomGridLine function I keep getting a "System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object." error during post back. This works fine when I add a chart to the form that is not inserted in the datalist control. See code below.
Partial Class Chart Inherits System.Web.UI.Page Dim AddAssyLines As String Dim Chart As ChartFX.WebForms.Chart Protected Sub ChartBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ChartBtn.Click AssyChkBox.Visible = False ChartBtn.Visible = False DataListRadar.Visible = True AddAssyLines = BuildValueList(AssyChkBox.Items, True) AssyLinesBTTlbl.Text = AddAssyLines Chart = DataListRadar.FindControl("Chart1") Dim custom1 As ChartFX.WebForms.CustomGridLine custom1 = New ChartFX.WebForms.CustomGridLine custom1.Value = 95 custom1.Color = System.Drawing.Color.DarkBlue custom1.Text = "Target 95%" custom1.Width = 2 Chart.AxisY.CustomGridLines.Add(custom1) End Sub Protected Function BuildValueList(ByVal items As ListItemCollection, ByVal itemMustBeSelected As Boolean) As String Dim idList As StringBuilder = New StringBuilder() For Each item As ListItem In items If itemMustBeSelected AndAlso (Not item.Selected) Then Continue For Else idList.Append(item.Value.ToString()) idList.Append(",") End If Next item Return idList.ToString() End FunctionEnd Class