Hey ,
i am using datagrid and i want to update the data by updating the grid text box values now how can i asign the values from grid and update data in visual studio .net
Printable View
Hey ,
i am using datagrid and i want to update the data by updating the grid text box values now how can i asign the values from grid and update data in visual studio .net
Please do the following things in the event of update command
Dim txtCustomerId As TextBox = CType(e.Item.Cells(3).Controls(0), TextBox)
Dim txtShipName As TextBox = CType(e.Item.Cells(5).Controls(0), TextBox)
Dim txtShipCity As TextBox = CType(e.Item.Cells(6).Controls(0), TextBox)
Dim txtShipRegion As TextBox = CType(e.Item.Cells(7).Controls(0), TextBox)
Dim txtShipPostalCode As TextBox = CType(e.Item.Cells(8).Controls(0), TextBox)
Dim CustomerId As String = txtCustomerId.Text
Dim ShipName As String = txtShipName.Text
Dim ShipCity As String = txtShipCity.Text
Dim ShipRegion As String = txtShipRegion.Text
Dim ShipPostalCode As String = txtShipPostalCode.Text
Dim cmd As SqlCommand
cmd = New SqlCommand("Update Orders set Shipname= '" & ShipName & "', ShipCity = '" & ShipCity & "' WHERE CustomerID = @CustomerId", conn)
cmd.Parameters.Add(New SqlParameter("@CustomerId", SqlDbType.VarChar, 20))
cmd.Parameters(0).Value = CustomerId
cmd.ExecuteNonQuery()
dgOrders.EditItemIndex = -1
FilterOrders()
Catch ex As SqlException
Response.Write(ex.Message)
End Try
:wave: :wave: