简体   繁体   中英

ASP.NET: Gridview Formatting Columns with DataFormatString

I want to change these values with DataFormatString properties in Gridview .

1.000000 --> 1 --> Deleting all digits after .

366705.000000 --> 366,705 --> Deleting all digits after . and put the comma for seperate.

12.830000 --> %12,83 --> Delete last 4 digits after . and put % (% is optinal not must)

BTW, Is there any link to suggest me otherwise DataFormatString . I analyze very well this page but sometimes still can't find what I need about data format string.

Here you go. I didn't test #3 - if it's not right, it's close.

1

Convert the number to an int .

2

String.Format("{0:n"}, 366705);

3

(12.83 / 100).ToString("{%#0.00}", el-GR);

A couple helpful formatting web pages:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM