dataset allows for nulls entityCollection doesn't

Posts   
 
    
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 26-Jul-2007 14:33:09   

asp.net 2.0 llblgenpro 2 adapterTemplate

hiya,

I have some lookup code in a the aspx of a gridView.

Text='<%# GetUserName(Eval("AssignedToUserId").ToString()) %>'

The corresponding code behind is:

protected string GetUserName(string userId)
    {
        if (!GuidHelper.IsValidGuid(userId))
        {
            return string.Empty;
        }
        return Membership.GetUser(new Guid(userId)).UserName;
    }

It works fine when I bind to a dataset. When I bind to an lblGenPro entityCollection (which grabs exactly the same data) I get an error (because the value can sometimes be null)

My question, can I change some setting so that this will work with llblGenpro WITHOUT me having to change any code?

many thanks,

yogi

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Jul-2007 16:34:56   

Would you please try the following?

Text='<%# GetUserName(Eval("AssignedToUserId")) %>'

protected string GetUserName(object userId)
{
    If(object != null)
    {
    ...
    }
}
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 26-Jul-2007 17:14:21   

hiya Walaa,

it works, IF I change:

1) the aspx 2) the lookup function

As you suggested.

So, the answer to my question:

can I change some setting so that this will work with llblGenpro WITHOUT me having to change any code?

..is "No?"

Why is that? Why can't it just work the same that it did with a dataset?After all, it's hitting exactly the same database and same data.

many thanks.

yogi

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 27-Jul-2007 10:20:31   

In LLBLGen Pro, is the AssignedToUserId field, of nullable type?

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 27-Jul-2007 11:27:38   

hiya Walaa,

No, it's of "GUID" type.Therein lies the issue. Thanks for clarifying.

yogi