ASP. NET program keeps two decimal points for parsing

Source: Internet
Author: User

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.

  1. Analysis of ASP. NET connection string Traversal
  2. Analysis on the types and features of ASP. NET Cache
  3. Three methods of ASP. NET page Jump
  4. Analysis on the nature and connection of iis asp. NET
  5. Analysis of iis asp. NET process mode

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.