Listbox retrieval of data from multiple tables

Posts   
 
    
shughart
User
Posts: 5
Joined: 11-Nov-2006
# Posted on: 13-Jan-2007 19:25:39   

Hi I am a newbie user, great product makes my life sooo much easier.

The problem that I am facing is that I have 2 tables. MemberAttendLocation where members attend a certain location. And another related table LocationType table.

MemberAttendLocation table has a many to one relationship with LocationType type. MemberAttendLocation.LocationID(FK) to LocationType.LocationID (PK).

I want the LocationType.LocationName from MemberAttendLocation object to populate the listbox of all location types that the member attending locations. In LLBLGenPro designer I manually added the LocationType.LocationName in "Fields mapped on related fields". This was done in the MemberAttendLocation entity.

When I use MemberAttendLocationFieldIndex.AmountOfFields.ToString() it shows Entity path not the data, however, if I use LocationID the data populates the listbox correctly. Do I need to cast this or do it in a different way??


// Populate listbox
lbxLocations.ValueMember = MemberAttendLocationFieldIndex.MalId.ToString();
lbxLocations.DisplayMember = MemberAttendLocationFieldIndex.AmountOfFields.ToString();
lbxLocations.DataSource = MemberAttendLocationEntity.GetMemberAttendCollection();

// 
public static MemberAttendLocationCollection GetMemberAttendCollection(){
MemberAttendLocationCollection MemberAttendCollec = new MemberAttendLocationCollection();
            MemberAttendCollec.GetMulti(null); 
            
return MemberAttendCollec;
}

Thanks, I'm using LLBLgen Pro and .net 2.0 with C# windows forms.

Chester
Support Team
Posts: 223
Joined: 15-Jul-2005
# Posted on: 14-Jan-2007 00:05:18   

First, welcome to the world of LLBLGen Pro!

OK, let's take a step back and ask this - are you trying to create a list box that has a list of Locations, and then you want the selected item's value to become the value of the MemberAttendLocation.LocationID?

shughart
User
Posts: 5
Joined: 11-Nov-2006
# Posted on: 14-Jan-2007 02:34:53   

Hi Chester,

Thanks for the response, what I am trying to do is the following:

I have 1 table (MemberAttendLocation) this table contains information on which locations someone can attend. Now I also have a table called LocationType this contains the name of all the locations. What I want to do is show the location names that a person is allowed to go to. But when I add this in LLBLGen it shows an entity relationship in the listbox and not the actual data.

shughart
User
Posts: 5
Joined: 11-Nov-2006
# Posted on: 14-Jan-2007 03:47:22   

I figured it out.

I used the "LocationName" explicitly as a string instead of using the enums. I had to do this as a work around but it works.

Thanks tho.