C#:datagridview数据表隐藏字段不为null [英] C#: datagridview datatable hidden field not null

查看:296
本文介绍了C#:datagridview数据表隐藏字段不为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



datagridview dgv是从数据表dt中填充的.

dt中隐藏了dt中的字段之一,即在数据库表中不为null的field3.在dgv本身中,我可以添加一个新行,但是系统希望我为field3添加一个值,因为它在数据库表中不为null.

问题:
是否可以在此field3中添加一个伪值,即使它是隐藏的,以便当它不抱怨必须在field3中添加新值时?

谢谢

Hi,

datagridview dgv is populated from a datatable dt.

One of the fields in dt i.e. field3 which is not null in the database table is hidden in the dgv. In the dgv itself, I can add a new row but the system wants me to add a value for the field3 because it is not null in the database table.

Question:
Is it possible to add a dummy value to this field3 even though it is hidden so that when it does not complain about having to add a new value to field3?

Thanks

推荐答案

您可以在绑定数据表之前为其设置默认值.

这是有关默认值的MSDN信息:
http://msdn.microsoft.com/en-us/library/system. data.datacolumn.defaultvalue.aspx [ ^ ]
You could set a default value to the datatable before binding it.

Here is the MSDN info on default values:
http://msdn.microsoft.com/en-us/library/system.data.datacolumn.defaultvalue.aspx[^]


这篇关于C#:datagridview数据表隐藏字段不为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆