Step 5. Update Data in a File

In this step you will add an Update push button, and add logic to update the record, setting the fields to their default value when successful.

1.  Add a third push button to the second row. On the Details tab:

a.  Give the button a Caption of Update.

b.  Change the Name to Update

c.  Create a Click event.

d.  Select the Layout ribbon:

e.  Change Alignment to Top Left and Flow to Right

f.  Change margin Top and Left to 20.

2.  Complete the Update.Click event by adding code to invoke the Save method.

3.  Compile and test your web page. Enter 50 and Fetch the record you added earlier. Change the description and click Update. Note that if successful the fields are set to their default value.

     Fetch the 50 record again. Clear the description field and click Update. Note that the department code is not cleared because the update failed. You have not yet added error handling. The update failed because a validation rule for field xDepartmentDescription tests the field value and creates an error message if it is blank.