Datagrid|web| Control | issues
The information in the DataGrid control is eventually displayed in an HTML table in the Web Forms page, so you can set the values for each column to control how the data is displayed. NET string format, when the AutoGenerateColumns property of the DataGrid is set to True, the format of the generated column is not allowed to be specified, only for bound columns or template columns.
To format the data, you need to set the data format string property of the column to a string format expression that adapts to the data type of the data, and the slightly more complicated character of the format string is that the same specified characters, such as D, can be applied to different data types (integer, date) depending on the result.
Note: In VS, you can specify the format expression in the Column tab of the Property Builder.
The following table lists some examples of formatting strings that you can get more information by looking at the format type and Boundcolumn.dataformatting properties topics in vs text.
A format expression applied to a data type description:
PRICE:{0:C}
Note: {0} is a 0, not letter O, value or decimal number displayed in currency format after the character "Price:" You can specify a different currency format by directly setting the culture property of the page or Web.config file.
{0:D4} applies to Integer (cannot be used for decimal data). Four-digit group, vacancy 0.
{0:n2}% applies to decimal numbers. Displays the number before the character%, accurate to two digits after the decimal point.
{0:000.0} applies to numeric/decimal numbers. Keep one digit after the decimal point, and less than three digits before the decimal point is 0.
{0:D} applies to date/date times. Use long time format such as: ("Thursday, August 06, 1996").
The date format depends on the culture settings of the page page or Web.config file.
{0:D} applies to date/date times. Use a short date format, such as (" 12/31/99"). {0:YY-MM-DD} is applied to date/time and is displayed in the year-month-day format, such as: ( 96-08-06).
(unfinished)