Hi,
I have an editable datagridview that's been databound with dataadapter and datatable, and a normal button on a form. When i edit the dgv's cells and click the save button it fires the datagridview_cellvalidating event and if the cell validation is correct it updates and saves the current record to the datasource. Also, before save it commits change in any cell under editing.
But when I use a toolstripbutton to do the same work, though it saves the dgv records but doesn't update the current change i.e. it saves the old records that are being fetched when the dgv was populated first during form load. Also, clicking the toolstripbutton doesn't fire datagridview_cellvalidating, datagridview_rowvalidating etc events. What it seems to be is it's not commiting the change in any cell under editing. Example-

Dgv While load:

CustomerID Customer Inactive
________________________________________
C01 Max Yes
C02 John No
C03 Alex Yes

Dgv while edit but before clicking toolstrip save button:

CustomerID Customer Inactive
________________________________________
C01 Max Yes
C02 Tim Yes
C03 Alex Yes

Dgv after clicking the toolstrip save button:

CustomerID Customer Inactive
________________________________________
C01 Max Yes
C02 John No
C03 Alex Yes

Why isn't it happening and how can I make it work? Please Help. Please also let me know how can I fire datagridview_cellvalidating, datagridview_rowvalidating and other events; and commit cell value change by clicking toolstripbutton. Regards.

Write either of the following in toolstripbutton click event:

DataGridViewName.EndEdit()

Or

Me.Validate()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.