数据集的问题!急! 是这样的,我的其中一个字段是日期类型,而SQL数据库日期在写入的时候不能为空值,所以我当用户没填的时候就写入"2001-1-1" 现在读出来要显示在dataGrid上,想把此字段的等于2001-1-1的显示成空白,要如何处理!请高手给个方法! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给此单元格赋值为DBNull.Value这样的话有些正常就是有填的数据也变成了空了啊 你把单元格值为"2001-1-1"才转换为DBNull.Value啊,在转换之前要写判断条件啊。 SQL数据库日期在写入的时候不能为空值,当用户没填的时候就写入"2001-1-1" ??自相矛盾。。可不填则非必填咯,为何还不能为空? select case datetimeField when 2001-1-1 then '' else datetimeField from .. protected void dataGrid_DataBound(object sender , EventArgs e){ for(int i=0;i<dataGrid.Rows.Count;i++) { dataGrid.Rows[i].Cells[列索引].Text=dataGrid.Rows[i].Cells[列索引].Text=="2001-1-1"?string.Empty:dataGrid.Rows[i].Cells[列索引].Text; }} 用这个搞定 谢谢visir ! 也谢谢大家!select case when ecr_ann_date > '2001-01-01' then ecr_ann_date else null end from ecr C# 端口 高手请帮我看看这个存储过程怎么调用? 关于C#登陆框的做法 在WinForm中关于ListBox和ComboBox选中项的问题,希望高手指教! 关于页输出缓存 telerik 我如何让toolwindow控件系统通知这个控件窗体启动的时候自动折叠起来 如何使用C#开发Web程序(WebForm)网站??? c#调用c++DLL,关于非托管DLL资源如何在使用完后释放 关于 richTextBox frame的问题,大侠们帮忙! 请教vs的代码提示效果~~~~~~~~~~ 关于focus的问题 关于事件和委托
这样的话有些正常就是有填的数据也变成了空了啊
自相矛盾。。
可不填则非必填咯,为何还不能为空?
protected void dataGrid_DataBound(object sender , EventArgs e)
{
for(int i=0;i<dataGrid.Rows.Count;i++)
{
dataGrid.Rows[i].Cells[列索引].Text=dataGrid.Rows[i].Cells[列索引].Text=="2001-1-1"?string.Empty:dataGrid.Rows[i].Cells[列索引].Text;
}
}
select case when ecr_ann_date > '2001-01-01' then ecr_ann_date else null end from ecr