I keep getting this error message when I try this code, and I have never done this before (conditional formatting), so I am not sure if that is the issue or something else?
System.InvalidCastException: Unable to cast object of type 'System.EventArgs' to type 'System.Web.UI.WebControls.DataGridItemEventArgs'
This is the code:
Kai-What?
System.InvalidCastException: Unable to cast object of type 'System.EventArgs' to type 'System.Web.UI.WebControls.DataGridItemEventArgs'
This is the code:
Code:
Dim conMetrics As OleDbConnection = New OleDbConnection(connectString)
conMetrics.Open()
Dim strLot
Dim strPID
strLot = LotSelect.SelectedItem.Value
strPID = ProductSelect.SelectedItem.Value
Dim cmdSelect As OleDbCommand
If strLot = "Select Lot Number" Then
cmdSelect = New OleDbCommand("Select * From Metrology Where [PART No_:] = '" & strPID & "' order by [Date_Time] desc", conMetrics)
ElseIf strPID = "Select Product ID" Then
cmdSelect = New OleDbCommand("Select * From Metrology Where [Lot No_:] = '" & strLot & "' order by [Date_Time] desc", conMetrics)
Else
cmdSelect = New OleDbCommand("Select * From Metrology Where [Lot No_:] = '" & strLot & "' AND [PART No_:] = '" & strPID & "' order by [Date_Time] desc", conMetrics)
End If
Dim DataReader As OleDbDataReader
DataGrid1.DataSource = cmdSelect.ExecuteReader
DataGrid1.DataBind()
Dim Sub1, Sub2 As String
Dim myInteger As Integer
If (e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingItem) Then
If (e.Item.Cells(3).Text) < "6" Then _
e.Item.Cells(3).BackColor = System.Drawing.Color.FromName("#ffccff")
If e.Item.DataItem("Length Top XD") > "5.5" Then _
e.Item.Cells(3).BackColor = System.Drawing.Color.DeepPink
End If
conMetrics.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Page.IsPostBack Then
Datagrid1_ItemDataBound(Me, New System.EventArgs)
End If
End Sub
Kai-What?