Tuesday, March 6, 2012
Orders: Setting Default Date

When creating a new order, the order date should default to the current date.

Switch back to the Designer, and expand the Orders controller in the Explorer. Expand Fields, and double click on OrderDate.

In the Code Default property, write:

DateTime.Now

Setting Code Default for OrderDate field in Code On Time Designer

Press OK to save the field. Press Generate in the top left corner, and wait for the page to load. Navigate to Order Form, and create a new order. Select a customer and employee. You will see that the current date has been inserted into the Order Date field.

Current Date inserted in Order Date for the Order Form