动态表中的时间控件如何在保存时更改时间格式
我在动态表中用时间控件选中时间,保存时想进行格式转换成2011-08-21的格式,但是储存的却是2011-8-21 0:00:00,望高手指点!这个是界面:
<table id="tableA" cellspacing="1" cellpadding="4" class="rpTable">
<tr>
<td colspan="4" class="rpTableCaption">产品检验认证</td>
</tr>
<tr>
<td class="rpTdItem">认证名称</td>
<td class="rpTdItem">认证时间</td>
</tr>
<!-- 动态行开始标记行 -->
<tr id="DynamicBegin" style="display:none"><td></td></tr>
<!-- 模板行(在该行前添加) -->
<tr id ="TemplateRow" style="display:none">
<td class="rpTdItemValue">
<input type="text" class="rpTextBox" onchange="OnDynaChanged(this);" />
</td>
<td class="rpTdItemValue">
<input type="text" class="rpTextBox" onclick="calendar();"/>
</td>
</tr>
</table>
CS代码:
// 保存产品检验认证信息
protected void SaveDoorCertificationInfo()
{
DoorCertificationInfoBR doorcertificationinfoBR = new DoorCertificationInfoBR();
DoorCertificationInfo doorcertificationinfo = new DoorCertificationInfo();
string strData = hfdDCinfoData.Value;
string[] strDCFinfo = strData.Split(DataFormator.EOL);
string time = null;
for (int i = 0; i < strDCFinfo.Length; i++)
{
string[] strItems = strDCFinfo[i].Split(DataFormator.SOI);
DoorCertificationInfo dcinfo = new DoorCertificationInfo();
dcinfo.ProductID = productID;
dcinfo.Name = strItems[0];
dcinfo.CertificationTime = System.DateTime.Parse(strItems[1]);//这里后面没发加.ToString("yyyy-MM-dd")
doorcertificationinfoBR.Add(dcinfo);//存入数据库
}
}
本人在线等~~~~~请诸位指点! --------------------编程问答-------------------- 先自己顶一下,有哪位能帮解决一下啊,我弄了一晚上没弄出来。。。 --------------------编程问答-------------------- 你表中的字段是DateTime类型的是不? --------------------编程问答--------------------
dcinfo.CertificationTime = System.DateTime.Parse(strItems[1],"yyyy-MM-dd");//这样就提示错误
错误提示:
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误消息: CS1502: 与“System.DateTime.Parse(string, System.IFormatProvider)”最匹配的重载方法具有一些无效参数
--------------------编程问答-------------------- 是时间类型
--------------------编程问答--------------------
截图看:
[img=C:\Documents and Settings\xiajiefu\桌面][/img] --------------------编程问答-------------------- string s = = System.DateTime.Parse(strItems[1]);
dcinfo.CertificationTime=s.ToShortDateString() --------------------编程问答-------------------- string s = = System.DateTime.Parse(strItems[1]).ToShortDateString();
dcinfo.CertificationTime=s; --------------------编程问答-------------------- 间接的做个转换! --------------------编程问答-------------------- --------------------编程问答-------------------- string s = = System.DateTime.Parse(strItems[1]);
dcinfo.CertificationTime=Covert.ToDateTime(s); --------------------编程问答-------------------- CertificationTime 是 DateTime类型的是不? --------------------编程问答--------------------
不行? --------------------编程问答-------------------- CS0029: 无法将类型“string”隐式转换为“System.DateTime”
--------------------编程问答-------------------- CS0103: 当前上下文中不存在名称“Covert”
--------------------编程问答-------------------- 是时间类型~
补充:.NET技术 , C#