The Data Format String is used to format the value of a field before it is presented to the end user. It can be specified on the field itself, and will be applied to all instances of the field bound to the views (data fields). If it is specified on the data field level, then only that data field will use the data format string.
The Unit Price data fields in the Products controller are assigned the currency data format string of “c” by default.
Let’s assign the data field on the grid view a different format string.
Start the Project Designer. In the Project Explorer, double-click on Categories / Products / container1 / view1 / grid1 / UnitPrice data field node.
Change the Data Format String property:
Property | New Value |
Data Format String | c4 |
Press OK to save the data field. On the toolbar, press Browse, and wait for the web application to load in your default browser.
Navigate to the Products page. The Unit Price data field on the grid view will be formatted with four numbers after the decimal place.
Select a record. The Unit Price data field on the edit form will be formatted with the standard two numbers after the decimal place.