【发布时间】:2018-01-20 18:38:05
【问题描述】:
当我在 dataBindingSource 中插入一个新行时,我想为一个字段分配一个默认值,这样如果用户没有输入任何值,这个值就会被默认分配。我不能在数据库中保留这个默认值,因为它可能会因场合而异。
那么,在用户点击插入按钮后,使用 dataBindingSource,如何将列(在插入的新行中)分配给默认值(预先确定)?我想过使用dataBindingSource的AddingNew事件。
我正在使用具有 bindingSource 和 tableAdapter 的数据集。我接受其他方法建议。
【问题讨论】:
-
你使用过DataTable对象吗?
-
不,我没有。我的表单只有以下数据控件:dataSet、tableAdapter 和 bindingSource。但我接受有关上述问题的任何建议。
-
您也可以在数据集设计器中设置一个默认值。
标签: c# dataset strongly-typed-dataset