两种方法 1)在ItemDataBound事件中写 if(e.Item.ItemIndex >= 0) { if (e.Item.Cells[列的Index].Text=="1900-01-01") { e.Item.Cells[列的Index].Text==""; } }2)在查询语句里写 select 其他的列,case 时间列 when '1900-01-01' then '' end as 时间列 from 表名
1)写错了 e.Item.Cells[列的Index].Text=="";应该写成 e.Item.Cells[列的Index].Text="";2)也写错了 select 其他的列,case 时间列 when '1900-01-01' then '' else 时间列 end as 时间列 from 表名
问题解决了,正确的SQL语句应该这样写: select recdate=case recdate when '1900-01-01' then '' else substring(convert(char(10),recdate,120),1,10) end from ord10104 还是很感谢大家给我提供思路,如果哪个朋友知道在DATAGRID中如何屏蔽,请告诉我,不胜感激。
1)在ItemDataBound事件中写
if(e.Item.ItemIndex >= 0)
{
if (e.Item.Cells[列的Index].Text=="1900-01-01")
{
e.Item.Cells[列的Index].Text=="";
}
}2)在查询语句里写
select 其他的列,case 时间列 when '1900-01-01' then '' end as 时间列 from 表名
select 其他的列,case 时间列 when '1900-01-01' then '' else 时间列 end as 时间列 from 表名
select recdate=case recdate when '1900-01-01' then '' else substring(convert(char(10),recdate,120),1,10) end from ord10104
还是很感谢大家给我提供思路,如果哪个朋友知道在DATAGRID中如何屏蔽,请告诉我,不胜感激。