datagridview dgv is populated from a datatable dt.
Within dgv I can add records as the grid allows adding a new record.
Before clicking on the save button, how can I check if the added records is already present in the dgv?
Thanks
Printable View
datagridview dgv is populated from a datatable dt.
Within dgv I can add records as the grid allows adding a new record.
Before clicking on the save button, how can I check if the added records is already present in the dgv?
Thanks
How do you normally see what data is in the database? You execute a query. Same goes here. How do you specify what record to look for when you update or delete? With a WHERE clause. Same goes here. You obviously don't need the actual data, only to know whether it exists, so you can use the appropriate count function for your database. A non-zero result means that the data exists.
solved by checking the rowstate.
Thanks
If that really was the solution then I must have severely misinterpreted the question. Maybe, or maybe not, you could then call the GetChanges method of the DataTable. You can specify a DataRowState and get a new Datatable containing just the rows with that state.