G
Guest
I'm working with a DataGrid UpdateCommand event and running into a problem.
The second column of the dg is the PK named "FlitchNum". The datatype of
this PK is varchar(string). In the event I need to obtain the value of this
field in order to pass it into a SQL command. However, when I use the
syntax: "Dim FlitchID As String = e.Item.Cells(1).Text" nothing populates the
FlitchID variable. Below is the code. How do I simply select the textual
value of the contents of column 3? Thanks
-------------------------------------------------------------------------------------
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(2).Controls(1), DropDownList)
Dim NewShip As Integer = DDL.SelectedValue
Dim FlitchID As String = e.Item.Cells(1).Text
Response.Write(FlitchID)
Dim SQL As String = _
"UPDATE tblLogs SET SpecieID=@Specie WHERE FlitchID=@ID"
Dim Conn As SqlConnection = New SqlConnection("integrated
security=SSPI;data source=sjserver1;persist security info=False;initial
catalog=sjerp")
Dim Cmd As New SqlCommand(SQL, Conn)
Cmd.Parameters.Add(New SqlParameter("@Specie", NewShip))
Cmd.Parameters.Add(New SqlParameter("@ID", FlitchID))
Conn.Open()
Cmd.ExecuteNonQuery()
Conn.Close()
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind(
-------------------------------------------------------------------------------------
The second column of the dg is the PK named "FlitchNum". The datatype of
this PK is varchar(string). In the event I need to obtain the value of this
field in order to pass it into a SQL command. However, when I use the
syntax: "Dim FlitchID As String = e.Item.Cells(1).Text" nothing populates the
FlitchID variable. Below is the code. How do I simply select the textual
value of the contents of column 3? Thanks
-------------------------------------------------------------------------------------
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(2).Controls(1), DropDownList)
Dim NewShip As Integer = DDL.SelectedValue
Dim FlitchID As String = e.Item.Cells(1).Text
Response.Write(FlitchID)
Dim SQL As String = _
"UPDATE tblLogs SET SpecieID=@Specie WHERE FlitchID=@ID"
Dim Conn As SqlConnection = New SqlConnection("integrated
security=SSPI;data source=sjserver1;persist security info=False;initial
catalog=sjerp")
Dim Cmd As New SqlCommand(SQL, Conn)
Cmd.Parameters.Add(New SqlParameter("@Specie", NewShip))
Cmd.Parameters.Add(New SqlParameter("@ID", FlitchID))
Conn.Open()
Cmd.ExecuteNonQuery()
Conn.Close()
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind(
-------------------------------------------------------------------------------------