What is the formatting Method for ASP. NET strings? What is the usage of the ASP. NET string formatting and display method? So next let's take a look at what exactly is there?
- Date. ToString ("MM-yyyy", DateTimeFormatInfo. InvariantInfo)
And so on.
ASP. NET string formatting 1. Date formatting method when binding:
- ﹤ASP:BOUNDCOLUMN DATAFIELD= "JoinTime "
- DATAFORMATSTRING= "{0:yyyy-MM-dd} " ﹥
- ﹤ITEMSTYLE WIDTH= "18% " ﹥ ﹤/ITEMSTYLE ﹥
- ﹤/ASP:BOUNDCOLUMN ﹥
ASP. NET string formatting 2. Data controls such as DataGrid/DataList:
- e.Item.Cell[0].Text = Convert.ToDateTime(
- e.Item.Cell[0].Text).ToShortDateString();
ASP. NET String formatting 3. Convert the date display format with the String type:
- String.Format( "yyyy-MM-dd ",yourDateTime);
ASP. NET string formatting 4. Convert the date display format using the Convert method:
- Convert. ToDateTime ("2005-8-23"). ToString
- ("YyMMdd", System. Globalization.
- DateTimeFormatInfo. InvariantInfo );// Supports traditional databases
ASP. NET string formatting 5. Convert the date display format using the ToString method directly:
- DateTime.Now.ToString("yyyyMMddhhmmss");
- DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss")
ASP. NET string formatting 6. display only the year and month
- DataBinder.Eval(Container.DataItem,"starttime","{0:yyyy-M}")
ASP. NET string formatting 7. display all parts of the time, including: year, month, day, hour, minute, and second
- <Asp: BoundColumn DataField ="Receipt time"HeaderText ="Receipt time"
- DataFormatString ="{0: yyyy-MM-dd HH24: mm: ss }">
- </Asp: BoundColumn>
The basic content of the ASP. NET string formatting and display method is introduced here. I hope to help you understand and learn ASP. NET string formatting and display methods.
- In-depth research on Repeater controls: Maximum Flexibility
- Getting started with DataList controls
- Exploring the operation mechanism of the DataGrid Web Control
- Discuss the similarity between ASP. NET data Web controls
- Transformation from traditional ASP to ASP. NET: Understanding controls