DevExpress inherited ComboEdit crashes in Descriptor.SetValue


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I understand....what I was trying to say in my previous post is that something within the DevExpress is trying to set the field to DbNull...not empty.  And since that field is not setup to support a Null value, you get the exception.  I would first investigate why the DevExpress field is trying to set the bound field to DbNull...that is where your error is coming from.
George Nentidis
George Nentidis
StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)
Group: Forum Members
Posts: 72, Visits: 251
Basically I want to prevent the exception from happening. It is valid for the specific field to be empty, but when I try to leave the text box empty, I get the exception. I try to find a way to do that without the exception.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
The Value object on the right of the assignment is DBNull, and this is why the cast fails. How can I overcome this?

I have not spent a lot of time in DevExpress lately, but I believe there is an option that when the field is cleared to reset the bound value to DbNull.  That sounds like what is happening.  If you do have the need for the field to be reset to DbNull, then you need to add the DbNull support to the field through the BOMapper customization for that field.  You can return an alternate value on Null or use a Nullable generic.  If you make a change through the BO Mapper, be sure to rebuild the partial class so that the Null logic gets built into the BO.

But from the sounds of it I think that you just want to prevent the textbox from setting the value to DbNull.

George Nentidis
George Nentidis
StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)StrataFrame User (136 reputation)
Group: Forum Members
Posts: 72, Visits: 251
I am using the DevExpress inherited ComboBoxEdit. I populate the object with a BO (detail), and I set the BusinessObject and BindingFiled properties to my master BO and the foreign key property respectivelly. The property that is the foreign key (and thus the Value of the combo) is of type Guid.

Everything works fine, the combo is populated, I can select from the list etc.

If by editing I clear the text of the combo, as if a wanted no value for the field (which is perfectly leagal in my case),

then I get an InvalidCastException inside the descriptor of the property at:

public override void SetValue(Object component, object Value)
{
      ((CustomerBO)component).RefererID = (System.Guid)Value;
}

The Value object on the right of the assignment is DBNull, and this is why the cast fails. How can I overcome this?

Thanks

This thing is giving me a bit of a hard time

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search