Hello... Im having a problem getting a datagrid to update.
Everything in my code looks ok so Im at a loss. I can
click update and the grid will rebind... but not with my
updated data. I am not posting back in pageload... And its
not database permissions cause I can do inserts. Please
Help! here is my code:
Sub dgStaff_Update( ByVal sender As Object, ByVal e As
DataGridCommand EventArgs)
'Get values out of the datagrid to update
Dim intID As Integer = e.Item.Cells(0) .Text
Dim strGrp As String = e.Item.Cells(1) .Text
Dim nameTextBox As TextBox = e.Item.Cells
(2).FindControl ("txtDGName" )
Dim posTextBox As TextBox = e.Item.Cells
(3).FindControl ("txtDGPos")
Dim numTextBox As TextBox = e.Item.Cells
(4).FindControl ("txtDGNum")
Dim strSql As String = "UPDATE tbl_parishstaff Set
person=@person, pos=@pos, num=@num WHERE id=@id"
'Create new update object and add parameters
Dim updateClergySta ff As OleDb.OleDbComm and = New
OleDb.OleDbComm and(strSql, Me.OleDbConnect ion1)
updateClergySta ff.Parameters.A dd("@id", intID)
updateClergySta ff.Parameters.A dd("@grp", strGrp)
updateClergySta ff.Parameters.A dd("@person",
nameTextBox.Tex t)
updateClergySta ff.Parameters.A dd("@pos",
posTextBox.Text )
updateClergySta ff.Parameters.A dd("@num",
numTextBox.Text )
'Open the database, update the data, close
database.
updateClergySta ff.Connection.O pen()
updateClergySta ff.ExecuteNonQu ery()
Response.Write( updateClergySta ff.ExecuteNonQu ery.)
updateClergySta ff.Connection.C lose()
'After updating data fill grid with updated info
and return to normal state
dgStaff.EditIte mIndex = -1
daStaff.Fill(Ds Staff1)
dgStaff.DataBin d()
End Sub
Everything in my code looks ok so Im at a loss. I can
click update and the grid will rebind... but not with my
updated data. I am not posting back in pageload... And its
not database permissions cause I can do inserts. Please
Help! here is my code:
Sub dgStaff_Update( ByVal sender As Object, ByVal e As
DataGridCommand EventArgs)
'Get values out of the datagrid to update
Dim intID As Integer = e.Item.Cells(0) .Text
Dim strGrp As String = e.Item.Cells(1) .Text
Dim nameTextBox As TextBox = e.Item.Cells
(2).FindControl ("txtDGName" )
Dim posTextBox As TextBox = e.Item.Cells
(3).FindControl ("txtDGPos")
Dim numTextBox As TextBox = e.Item.Cells
(4).FindControl ("txtDGNum")
Dim strSql As String = "UPDATE tbl_parishstaff Set
person=@person, pos=@pos, num=@num WHERE id=@id"
'Create new update object and add parameters
Dim updateClergySta ff As OleDb.OleDbComm and = New
OleDb.OleDbComm and(strSql, Me.OleDbConnect ion1)
updateClergySta ff.Parameters.A dd("@id", intID)
updateClergySta ff.Parameters.A dd("@grp", strGrp)
updateClergySta ff.Parameters.A dd("@person",
nameTextBox.Tex t)
updateClergySta ff.Parameters.A dd("@pos",
posTextBox.Text )
updateClergySta ff.Parameters.A dd("@num",
numTextBox.Text )
'Open the database, update the data, close
database.
updateClergySta ff.Connection.O pen()
updateClergySta ff.ExecuteNonQu ery()
Response.Write( updateClergySta ff.ExecuteNonQu ery.)
updateClergySta ff.Connection.C lose()
'After updating data fill grid with updated info
and return to normal state
dgStaff.EditIte mIndex = -1
daStaff.Fill(Ds Staff1)
dgStaff.DataBin d()
End Sub
Comment