Updating data in datagrid

09-Apr-2015 20:04

Once the Framework Element is extracted, by type casting it to the ‘Text Box’ UI element, the value changed in the cell can be read.

Here ‘Salary’ and ‘Dept No’ are changed and updated into the selected ‘Employee’ object.

Abstract: I was recently working on a requirement to perform Update and Delete operations on a WPF Data Grid control (similar to what developers do in a ASP. The WPF Data Grid is an excellent control to bind with collections and provides various events to work with. Now since Salary and Dept No can be updated, on the click event of the ‘Update’ button, the following code is written.

updating data in datagrid-35

Sri lankan adult web cam

The Template column generates buttons for all rows, which will add buttons for the last row where no data is present.

So the ‘if’ statement in the above code, will prevent the application from crashing, since the WPF Data Grid generates a blank row when the data is bound to it.