How can I solve the problem that ASP. NET programs retain two decimal places?
Problem: to display the time in the Datagrid AS 2.08 hours, I am doing this in SQL: SELECT 125/60 .00 AS float
But it is displayed as 2.083333 in the Datagrid. How can I write code to keep only two decimal places of 2.08?
◆ Two decimal places are reserved. Answer 1:
Float7, 2)
2 indicates that two decimal places are retained.
◆ Two decimal places are reserved. Answer 2:
Float8, 2 )? Where can I write it?
◆ Two decimal places are reserved. Answer 3:
In the Property builder of the datagrid, the column and data format setting expression are added:
{0: f2}
◆ Two decimal places are reserved. Answer 4:
1. In SQL statements: select convert (dt, numeric (5, 2) from
2. Add: {0: f2} in the data format column of the BIND column of the datagrid}
◆ Two decimal places are reserved. Answer 5:
Choose one
◆ Two decimal places are reserved. Answer 6:
Is that true? "select convert (125/60. 00, numeric () from "?
An error occurred while writing the code...
◆ Two decimal places are reserved. Answer 7:
Select round (125/60)
◆ Two decimal places are reserved. Answer 8:
Select cast (125/60. 00 as numeric ))
◆ Two decimal places are reserved. Answer 9:
Thank you.
What is the difference between round and cast?
◆ Two decimal places are reserved. Answer 10:
Set the corresponding field in the database to decimal, and change its decimal point to 2.
◆ Two decimal places are reserved. Answer 11:
Write e. item. cell [0]. text = float7, 2). Tostring () in the OnItemDataBound event of the Datagrid ()
It is converted and displayed in column 0th of dg.
◆ Two decimal places are reserved. Answer 12:
Many methods are identified
1. The field type is numeric and the decimal point is set to 2.
2. Conversion in SQL statements: select convert (field, numeric () AS field Ex from table
For a datagrid-bound column <Columns>, <asp: BoundColumn DataField = "field Ex"/>
3. Use this in the attribute of the columns bound to the datagrid.
<Asp: BoundColumn DataField = "field" DataFormatString = "{0: f2}"/>
The ASP. NET program will show you how to retain two decimal places and hope to help you.
- Analysis of ASP. NET connection string Traversal
- Analysis on the types and features of ASP. NET Cache
- Three methods of ASP. NET page Jump
- Analysis on the nature and connection of iis asp. NET
- Analysis of iis asp. NET process mode