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_Updat eCommand(ByVal source As Object, _
ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
Handles DataGrid1.Updat eCommand
Dim DDL As DropDownList = _
CType(e.Item.Ce lls(2).Controls (1), DropDownList)
Dim NewShip As Integer = DDL.SelectedVal ue
Dim FlitchID As String = e.Item.Cells(1) .Text
Response.Write( FlitchID)
Dim SQL As String = _
"UPDATE tblLogs SET SpecieID=@Speci e WHERE FlitchID=@ID"
Dim Conn As SqlConnection = New SqlConnection(" integrated
security=SSPI;d ata source=sjserver 1;persist security info=False;init ial
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.ExecuteNonQ uery()
Conn.Close()
DataGrid1.EditI temIndex = -1
DataGrid1.DataB ind(
-------------------------------------------------------------------------------------
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_Updat eCommand(ByVal source As Object, _
ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) _
Handles DataGrid1.Updat eCommand
Dim DDL As DropDownList = _
CType(e.Item.Ce lls(2).Controls (1), DropDownList)
Dim NewShip As Integer = DDL.SelectedVal ue
Dim FlitchID As String = e.Item.Cells(1) .Text
Response.Write( FlitchID)
Dim SQL As String = _
"UPDATE tblLogs SET SpecieID=@Speci e WHERE FlitchID=@ID"
Dim Conn As SqlConnection = New SqlConnection(" integrated
security=SSPI;d ata source=sjserver 1;persist security info=False;init ial
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.ExecuteNonQ uery()
Conn.Close()
DataGrid1.EditI temIndex = -1
DataGrid1.DataB ind(
-------------------------------------------------------------------------------------
Comment