如何将新添加的记录值检查到BindingSource

时间:2018-08-28 14:48:43

标签: c# sql database ado.net bindingsource

如何在将新记录添加到BindingSource之前将其检查到BindingSource中?

我想创建一种方法来检查绑定源中“添加的”行中的值并更新一些值,然后更新数据源

1 个答案:

答案 0 :(得分:0)

我想找到了解决方法

        DataRowView dataRowView = (DataRowView)bindingSource.Current;

        if (dataRowView.IsNew)
        {

            dataRowView[2] = NewValue; // change values 
            // but why here I cannot get the column by name like dataRowView["ID"] it returns DbNull 
        }

        BindingSource.EndEdit();