2

I am populating a datagrid with a dataset and I have my dataset verified for nullable values -

My problem is :

When the dataset is validating, it found empty rows and the errors are not displayed. I would like to define the empty cells with a DBNull.value. Is there any way to do it ?. I have found a property named TargetNullValue that could work ?

Angshuman Agarwal
  • 4,796
  • 7
  • 41
  • 89
Nandhi
  • 485
  • 4
  • 16

1 Answers1

2

I found a way to do it, by making a convertion

 public class ConvertStringToDBNull : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo cufo)
    {

        if (value is string)
        {
            if (value.ToString() == string.Empty)
            {
                return DBNull.Value;
            }
        }
        return value;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo cufo)
    {

        if (value is string)
        {
            if (value.ToString() == string.Empty)
            {
                return DBNull.Value;
            }
        }
        return value;
    }

}
Nandhi
  • 485
  • 4
  • 16