错误 1 无法将类型“string”隐式转换为“System.DateTime”

qq_33401683 2019-01-01 10:51:08
this.dateTimePicker1.Value = Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim();这个错误怎么修复呀
...全文
2097 22 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
PerDign 2019-01-09
  • 打赏
  • 举报
回复
DataTime.Parse( Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim() )
大鱼> 2019-01-09
  • 打赏
  • 举报
回复
DataTime.Parse
gishys 2019-01-07
  • 打赏
  • 举报
回复
需要类型转换
qq_44393202 2019-01-04
  • 打赏
  • 举报
回复
你两边类型不一样,string类型是不能隐式转换datetime类型,你可以用convert.todatetime()进行强制转换
lc011289 2019-01-04
  • 打赏
  • 举报
回复
左边时间控件的value是datetime类型的,右边是string类型的,强转一下试试
qq_33513833 2019-01-04
  • 打赏
  • 举报
回复
Convert.ToDateTime(dr["time"].ToString()).ToString("yyyy/MM/dd")
抢眼~ 2019-01-03
  • 打赏
  • 举报
回复
DataTime.Parse( Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim() )
悟V-SpHeNIC 2019-01-03
  • 打赏
  • 举报
回复
将日期串转成datetime类型
xiaoxiangqing 2019-01-03
  • 打赏
  • 举报
回复
string要符合日期格式才可以转为System.DateTime
xiaoyu5425 2019-01-02
  • 打赏
  • 举报
回复
强转,用强的不行就打死它
  • 打赏
  • 举报
回复
用显式转换吧,有没有DameTime()
gs0038 2019-01-02
  • 打赏
  • 举报
回复
this.dateTimePicker1.Value =DataTime.Parse( Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim() )
weixin_44363496 2019-01-02
  • 打赏
  • 举报
回复
两边类型,不一样
  • 打赏
  • 举报
回复
这种提示都不会解决啊…… 除了obj可以接收任何数据类型,否则必须类型对应才能赋值
浪子fred 2019-01-02
  • 打赏
  • 举报
回复
判断String的格式,根据格式转换
很闲hx 2019-01-02
  • 打赏
  • 举报
回复
this.dateTimePicker1.Value = Convert.ToDateTime(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim(); dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value 必须是yyyy-MM-dd hh:mm:ss
liusa1997 2019-01-01
  • 打赏
  • 举报
回复
convert.todatetime(Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim())
,本来就是string类型怎么可能直接赋值给datetime类型的
  • 打赏
  • 举报
回复
等号两边类型不兼容,根本不能赋值。这种语法错误,读代码时应该自己有意识吧。
xuzuning 2019-01-01
  • 打赏
  • 举报
回复
DataTime.Parse( Convert.ToString(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value).Trim() )
关中山水郎 2019-01-01
  • 打赏
  • 举报
回复
我服,这种问题完全是最基础的
加载更多回复(2)

111,097

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧