C# dev gridcontrol 'time' string formatting

黄舟
Release: 2017-02-21 11:04:29
Original
1672 people have browsed it

C# dev gridcontrol "time" string formatting

public  void FormateDate(ref DataSet ds, string colName)
{
	if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
	{
		foreach (DataRow dr in ds.Tables[0].Rows)
		{
			string ColumnValue = Convert.ToString(dr[colName]);
			while (ColumnValue.IndexOf(".") > 0)
			{
				ColumnValue = ColumnValue.Replace(".", "");
			}
			if (ColumnValue.Length >= 8)
			{
				dr[colName] = string.Concat(new string[]
				{
					ColumnValue.Substring(0, 4),
					".",
					ColumnValue.Substring(4, 2),
					".",
					ColumnValue.Substring(6, 2)
				});
			}
		}
	}
}
Copy after login

Function function:

Before binding the time to DEV gridcontrol, you can format 20090212 The formatted string is converted to the format of 2009.02.12 for easy use

Small Note:

String.Concat method: Connect one or more instances of String, or one or more instances of Object String representation of the value of multiple instances (if the argument is not of type string, it is first converted to a string using the string() function, and then the result of that conversion is evaluated). For specific explanation, see: Click to open the link

The above is the content of C# dev gridcontrol "time" string formatting. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!