|
-
April 6th, 2004, 06:41 AM
#1
Update Command in DataGrid
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
-
April 7th, 2004, 08:06 AM
#2
I have done it
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|