I have a grid that is populated from a BindingList (I am working with the EntityFramework)
The CellValueChanged event does apply the changes to the underlying database
But When I add a new row, the UserAddedRow (which is fired) does not add the row to the underlying database (and does not generate an error)
Despite long hours of research I have not found the solution to add a new row to my table by typing it's value in the "New Row" of the grid
Thanks in advance
The code snipet:
'Populate the Grid
Dim mArena As New mArena(context)
Dim allArenas As BindingList(Of Arena) = mArena.GetArenasByShowId(idShow)
gvArena.AutoGenerateColumns = True
gvArena.DataSource = allArenas
Public Function GetArenasByShowId(ByVal idShow As Integer) As BindingList(Of Arena)
Try
Dim Query = (From aArena As Arena In context.Arenas
Where aArena.idShow = idShow
Order By aArena.Name)
Return New BindingList(Of Arena)(Query.ToList())
Catch ex As Exception
RaiseEvent msg("F", ex.Message)
Return Nothing
End Try
End Function
'Grid Events
Private Sub gvArena_CellValueChanged(sender As Object, e As GridViewCellEventArgs) Handles gvArena.CellValueChanged
Try
context.SaveChanges()
Catch ex As Exception
RaiseEvent msg("F", "CellValueChanged: " & ex.Message)
End Try
End Sub
Private Sub gvArena_UserAddedRow(sender As Object, e As GridViewRowEventArgs) Handles gvArena.UserAddedRow
Try
gvArena.EndEdit()
context.SaveChanges()
Catch ex As Exception
RaiseEvent msg("F", "AddedRow: " & ex.Message)
End Try
End Sub