I am developing a web form and when I run it. I get an error that says 'Input String was not in correct format'. The error occurs in line one. Could someone help me in resolving this issue. Thanks.
Dim eventid As Integer = e.Item.Cells(1).Text 'Error here
Dim username As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Dim strevent As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
Dim strdate As String = CType(e.Item.Cells(4).Controls(0), TextBox).Text
Dim update_tblevent As String = _
"Update [tblevent] SET [event] = '" & strevent & "', " & _
"[date] = '" & strdate & "', " & _
"where [eventid] = eventid"
Dim selectedeventid As String = masterDataGrid.DataKeys(e.Item.ItemIndex)
Dim myCommand As New SqlCommand("UPDATE FROM tblEvent WHERE eventID=" & selectedeventid, connEvent)
myCommand.CommandType = CommandType.Text
connEvent.Open()
myCommand.ExecuteNonQuery()
connEvent.Close()
BindGrid()
Dim eventid As Integer = e.Item.Cells(1).Text 'Error here
Dim username As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Dim strevent As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
Dim strdate As String = CType(e.Item.Cells(4).Controls(0), TextBox).Text
Dim update_tblevent As String = _
"Update [tblevent] SET [event] = '" & strevent & "', " & _
"[date] = '" & strdate & "', " & _
"where [eventid] = eventid"
Dim selectedeventid As String = masterDataGrid.DataKeys(e.Item.ItemIndex)
Dim myCommand As New SqlCommand("UPDATE FROM tblEvent WHERE eventID=" & selectedeventid, connEvent)
myCommand.CommandType = CommandType.Text
connEvent.Open()
myCommand.ExecuteNonQuery()
connEvent.Close()
BindGrid()