I use combobox to filter a gridview, the gridview filtering occurs, but when i want to input a data in gridview in case that a grid have yet a lines (data), a message error displaying, so i cant enter a data, else when the grid have not at all data i can enter a value
the table behind gridview have an autogenerated field
Private Sub Le_clientComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Le_clientComboBox.SelectedIndexChanged Try Me.DevisBindingSource.Filter = "Code_client = '" & Le_clientComboBox.SelectedValue & "'" Catch ex As Exception MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Finally If con.State = ConnectionState.Open Then con.Close() End If End Try End Sub
the gridview is populated on load form
Private Sub frmDevis_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: cette ligne de code charge les données dans la table 'Tassaruf_tijariDataSet_Devis.Devis'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
Me.DevisTableAdapter.Fill(Me.Tassaruf_tijariDataSet_Devis.Devis)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub