I have a webform datagrid that errors out on the UpdateCommand event. The error occurs on the green line below, and the error is "Input string was not in a correct format." FlitchNum is the PK of the table bound to datagrid, and is also the 2'nd column of the datagrid. The datatype of FlitchNum is varchar. Is this error occuring because I need to format the green-line below to handle a varchar data type differently? Could someone help me understand why this error is occuring? Thanks.
--
Mike
Code:
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) _
Handles DataGrid1.UpdateCommand
Dim DDL As DropDownList = _
CType(e.Item.Cells(15).Controls(1), DropDownList)
Dim NewSpecie As Integer = DDL.SelectedValue
[COLOR=green][b]Dim FlitchNum As String = Int32.Parse(e.Item.Cells(1).Text)[/b][/color]
Dim SQL As String = _
"UPDATE tblLogs SET SpecieID=@SelectSpecie WHERE OrderID=@ID"
Dim ConnStr As String
ConnStr = "workstation id=LAPTOP;packet size=4096;integrated security=SSPI;data source=servername;persist security info=False;initial catalog=dbasename"
Dim Conn As SqlConnection = New SqlConnection(ConnStr)
Dim Cmd As New SqlCommand(SQL, Conn)
Cmd.Parameters.Add(New SqlParameter("@SelectSpecie", NewSpecie))
Cmd.Parameters.Add(New SqlParameter("@ID", FlitchNum))
Conn.Open()
Cmd.ExecuteNonQuery()
Conn.Close()
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
End Sub
--
Mike