or

Private Sub AddNew_Click(sender As System.Object, e As System.EventArgs) Handles AddNew.Click Try 'Add a new row Dim newrow As GridViewRowInfo = Me.NotesFrais.Rows.AddNew() 'Set default value on the new data object Dim newnotedefrais As NoteFrais = CType(newrow.DataBoundItem, NoteFrais) With newnotedefrais .DateCreation = Today.Date Dim currentuserguid As Guid = GetCurrentUser.Guid Dim currentcollaborateur As Collaborateur = Me._datactx.Collaborateur.Single(Function(c) c.AD_Guid.Equals(currentuserguid)) .Collaborateur = currentcollaborateur .IsTemporaire = True End With 'Update the database Me._datactx.SaveChanges() 'Select the new row newrow.EnsureVisible(True) newrow.IsSelected = True newrow.IsExpanded = True Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Une erreur est survenue..") End Try End Sub



