DataFormatString of data bindingSet the dataformatstring of BoundField, usually have the following severalDataformatstring= "{0:c}" currency, the format of the currency depends on the culture setting in the current threadDataformatstring= "{0:e}" scientific notationDataformatstring= "{0:p}" percentageDataformatstring= "{0:f}" several decimal placesDataformatstring= "{0:d}" m/d/yyyy as 10/30/2008Dataformatst
Today, when I helped a customer deploy a website, I found that there were several differences in the website that was previously well tuned locally, because local development was in the vs 2010 environment, the configuration of the customer space and the domain name is different from that of the local environment;
One problem is that dataformatstring in the gridview is invalid;
Solution:
When we obtain data entities from the business logic laye
There is a time to be displayed in the gridview, but it keeps the database in the standard time, very long, and only needs to display the date, you want to format the string, but the dataformatstring setting does not work, later, I checked and set htmlencode = false in "behavior ".
Dataformatstring = "{0: Format String }"{0} In dataformatstring represents the
Data Binding-dataformatstring
Set the dataformatstring of boundfield. There are usually the following types:Dataformatstring = "{0: c}" currency. The format of the currency depends on the settings of the culture in the current thread.Dataformatstring = "{0: e}" scientific notationDataformatstring = "{0: p}" percentageDataformatstring = "{0: F ?} "Number of decimal placesDataformatstring = "{0: d}" m/D/YYYY,
From: http://www.cnblogs.com/enuosky/archive/2006/08/29/489014.html
Dataformatstring = "{0: Format String }"
{0} In dataformatstring represents the data itself, while the format string after the colon represents the format they want to display the data;
Number and currency format:After the specified format symbol, you can specify the number of digits to be displayed in decimal places. For example,
String in dataformatstring formatDataformatstring = "{0: Format String }"
{0} In dataformatstring represents the data itself, while the format string after the colon represents the format they want to display the data;
Number and currency format:After the specified format symbol, you can specify the number of digits to be displayed in decimal places. For example, if the original data is "1.56" and the f
There is a time to be displayed in the gridview, but it keeps the database in the standard time, very long, and only needs to display the date, you want to format the string, but the dataformatstring setting does not work, later, I checked and set htmlencode = false in "behavior ".
Dataformatstring = "{0: Format String }"
{0} In dataformatstring represents the d
Asp.net| data when we render the data, we do not present the unmodified data to the user. For example, the amount of 10,000 yuan, if we directly display "10000", may lead to users as 1000 or 100,000, causing users to read data on the trouble. If we will be 10,000 yuan polished after the output for "nt$10,000", not only make it easier to read, but also allows users to reduce the chance of making mistakes.
To modify the output of a field, simply set the DataF
Dataformatstring = "{0: Format String }"
{0} In dataformatstring represents the data itself, while the format string after the colon represents the format they want to display the data;
Number and currency format:After the specified format symbol, you can specify the number of digits to be displayed in decimal places. For example, if the original data is "1.56" and the format is set to {0: N1}, the ou
Dataformatstring = "{0: Format String }"
We know that {0} In dataformatstring represents the data itself, while the format string after the colon represents the format that we want the data to display; in addition, after the specified format symbol, you can specify the number of digits to be displayed in decimal places. For example, if the original data is "12.34" and the format is set to {0: N1}, the o
Today by the DataFormatString attribute pit one day, the development environment Test format came out in line with the expectations, and the deployment to the production environment does not work, and later compared to the environment, with multiple virtual machines deployed different environment version to do the test, finally get the following points of understanding.① field type must be datetime type, this is not too much problem;Formatting pattern
Usage:
DataFormatString = "{0: Format String }"
{0} In DataFormatString represents the data itself, while the format string after the colon represents the format they want to display the data;
Number and currency format:After the specified format symbol, you can specify the number of digits to be displayed in decimal places. For example, if the original data is "1.56" and the format is set to {0: N1 },
Outp
Use the dataformatstring attribute to provide the custom formats of items in the column.
A data format string consists of two parts separated by a colon, in the form of {A: bxx }. For example, the formatted string {0: F2} displays the number of fixed points with two decimal places.
Note that the entire string must be placed in braces, indicating that it is a format string, not the actual string. Any text outside the braces is displayed as the ac
Symptom: When the gridview is bound to the date format, the date in the database is, while the gridview displays 000000. ,
Solution: If you want to remove this unused zero, you can add a sentence after the source code column of the binding time, as shown in the red section below.
CopyCodeThe Code is as follows: Dataformatstring = "{0: d}" htmlencode = "false"
Headerstyle-horizontalalign = "center"
Itemstyle-horizontalalign = "center">
If there
symptom (s): When the GridView binds the date format, the date in the database is 2008-07-04, and the GridView shows 2007-07-04 000000. 、
solution : Want to take this extra 0 out of the back in the binding time of the source code after adding a word on it, the following red part
Copy Code code as follows:
Dataformatstring= ' {0:d} ' htmlencode= ' false '
Headerstyle-horizontalalign= "Center"
itemstyle-horizontalalign= "Center" >
If
When we obtain data entities from the business logic layer, the next thing is to bind them to the control. Some fields in the data object can be directly bound to the interface, but some fields need to be reformatted. For example, for the currency unit field, you need to display the currency symbol and display the separator at every three places. For the date field, the database stores the date and time, however, the page is displayed in the format of xxxx, XX, and XX. In this case, the
Dataformatstring = "{0: N0} %"Dataformatstring = "$ {0: N2 }"Dataformatstring = "{0: N0"Dataformatstring = "No. {0: N0 }"Dataformatstring = "{0: yyyy-mm-dd hh: mm: SS }"
Data format setting expression
. NET Framework format setting expression, which is applied to data be
understand it. 2. databinder. eval implementation judgment select the dgformatsex method defined in CS protected string dgformatsex (string xb) {If (XB = "1") Return "male"; else return "female";} databinder. eval usage example databinder. eval usage example // show two decimal places //// {0: g} indicates to show true or false ////// Conversion Type (string) databinder. eval (container, "dataitem. p_ship_time_sbm8 ")). substring () {0: d} date only shows year month day {0: yyyy-mm-dd} display
1. Open Start Menu
2. Select the Microsoft. NET FrameWork in your program
3. Choose Documention
4. Select the Index tab
5. Enter "DataFormatString Property"
6. Double out the first keyword that appears.
7. The following content appears:
. NET Framework Class Library
Boundcolumn.dataformatstring Propertysee Also
BoundColumn Class | BoundColumn Members | System.Web.UI.WebControls Namespace | String.Empty | DataGrid | Formatting Overview
Requirements
Pl
) databinder. eval (container, "dataitem. p_ship_time_sbm8 ")). substring () {0: d} date only shows year month day {0: yyyy-mm-dd} display year month day {0: c} currency style by format
Dataformatstring usage notes
The syntax of the dataformatstring attribute is as follows:Dataformatstring = "{0: Format String }"We know that {0} In dataformatstring
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.