Sometimes during editing and/or inserting records we need to retrieve an additional information from the server side (for example, the value from a session, the value of a GET parameter or data from the database). To obtain such an information, the Ajax technique can be used.

The example below shows how to retrieve such information from the database. When a product is selected in the Insert form, the value of the Unit price editor is filled automatically based on the selected product.

To implement such a functionality, it is necessary to specify the following event handlers (click a name of a handler to see its code):

- OnInsertFormEditorValueChanged client-side event handler. Here the value of the selected product is sent via an Ajax request to the server to get the default unit price of this product. Then this price value is assigned to the Unit price editor (and can be later changed if necessary).
- OnPreparePage server-side event handler. Here the Ajax request is handled i.e. the product value is retrieved from the request, an SQL query is executed to get the price of the product and then the obtained price is returned as a response to the Ajax request.

Open the Insert form for Invoice details to see this feature in action.