ASP.NET binding to Nullable types

Posts   
 
    
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 17-May-2008 15:03:28   

I am having this problem that I am sure many of the Forum participants have faced and solved.

When LLBL generates an entity for a table, it uses a Nullable type for a column that allows NULL. When binding a combobox (Microsoft or 3rd party like Telerik) to an Entity's nullable property, I get a runtime exception when the property has a NULL value.

Is there a way to address this issue? rage

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-May-2008 19:51:12   

Hi Omar,

Why would be useful to show null values in a combo? Shouldn't you omit these null values from populate?

Anyway, Is the error about populate null values in a combobox or about linking the value of the combo with a FK in another entity?

Could you please post the relevant declarative ASPX and the relevant code-behind (if exists)?

David Elizondo | LLBLGen Support Team
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 18-May-2008 22:58:23   

Sorry for not being clear. What I mean here is NOT populating the combo's list (as you said it is simple to remove null entities from the list) but rather the combo's SelectedValue binded to a property that is the the FK referencing another entity.

I will try to prepare the ASPX markup to show it to you.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39873
Joined: 17-Aug-2003
# Posted on: 19-May-2008 16:25:31   

If you bind in code, just use the .HasValue and .Value properties on the Nullable field. Otherwise I've no idea how to solve this (sounds like an ASP.NET issue though...) What's the stacktrace?

Frans Bouma | Lead developer LLBLGen Pro