我已经限制其格式了,调试时也只显示了8/20/2003,可是在datagrid窗口中显示的就是2003-8-20 0:00:00,只想显示日期,怎么办?
For i = 0 To ds1.Tables(0).Rows.Count - 1
Format(ds1.Tables("WOA_PER_DAYPLAN_DEFINE").Rows(i).Item(2), "yyyy-MM-dd")
Next
...全文
2914打赏收藏
datagrid里日期型数据显示问题,帮帮小妹!
我已经限制其格式了,调试时也只显示了8/20/2003,可是在datagrid窗口中显示的就是2003-8-20 0:00:00,只想显示日期,怎么办? For i = 0 To ds1.Tables(0).Rows.Count - 1 Format(ds1.Tables("WOA_PER_DAYPLAN_DEFINE").Rows(i).Item(2), "yyyy-MM-dd") Next
there are two methods. one is processing datagrid after it is binded. the other is processing it with being binded.
1.
bindgrid();
foreach(datagriditem item in dgrd.items)
{
if(item.cells[2].text!=string.empty&&item.cells[2].text!="nbsp;")
item.cells[2].text=datetime.parse(item.cells[2].text).tostring("yyyy-MM-dd");
}
你没有保存格式化后的结果吧
For i = 0 To ds1.Tables(0).Rows.Count - 1
ds1.Tables("WOA_PER_DAYPLAN_DEFINE").Rows(i).Item(2)=Format(ds1.Tables("WOA_PER_DAYPLAN_DEFINE").Rows(i).Item(2), "yyyy-MM-dd")
Next