0

I used Infragistics WebDataGrid , I have BoundCheckBoxField column, I want remove partial check behavior. only check and uncheck

I wrote following class ,

public class BooleanConverter : IBooleanConverter 
{
    public BooleanConverter()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public object DefaultFalseValue
    {
        get { return false; }
    }

    public object DefaultTrueValue
    {
        get { return true; }
    }

    public bool IsFalse(object value)
    {
        if (value == null)
            return false;
        else
            return Boolean.Parse(value.ToString());
    }

    public bool IsTrue(object value)
    {
        if (value == null)
            return false;
        else
            return Boolean.Parse(value.ToString());
    }
}

` and I call it like this:

     ((BoundCheckBoxField)this.uwGrid.Columns["Approval"]).ValueConverter = new BooleanConverter();

`

But it is not work.

Lea Cohen
  • 7,990
  • 18
  • 73
  • 99

2 Answers2

2

The bound checkbox displays whatever data is bound to it. By default, for a boolean or nullable boolean field, it displays true as checked, false as unchecked, and null as partial. That's the only time it should show up- if you have null data.

If you do not like that behavior, you can assign the column a different ValueConverter. This would be a class that implements IBooleanConverter. You would make it so that null becomes checked or unchecked.

NT88
  • 947
  • 5
  • 25
1

I'm sure you figured it out by now, but there is a bug with your value converter class (assuming you want null to show as false). The IsFalse method should be like this:

public bool IsFalse(object value)
{
    if (value == null)
        return true;
    else
        return !Boolean.Parse(value.ToString());
}