Problem with identical Id names

Posts   
 
    
Karim
User
Posts: 14
Joined: 17-Dec-2007
# Posted on: 20-Dec-2007 16:44:46   

Hi,

I have the following code in my aspx page:

<EditItemTemplate> <aspsmile ropDownList ID="ddlContactSoort" runat="server" DataSourceID="LLBLGenProDataSource2" DataTextField="Naam" DataValueField="Id" AppendDataBoundItems="True" SelectedValue='<%# Bind("Id") %>'> <asp:ListItem></asp:ListItem> </aspsmile ropDownList> </EditItemTemplate>

The gridview has also a datasource with a primary column named "Id". This is being read in this part of the previous code : SelectedValue='<%# Bind("Id") %>'. Does LLBLGEN expect me to name the Id columns as <tablename>Id ? Or how can i distinguish between the two id's of the different datasources (which are both LLBLGENPRODATASOURCE controls).

Thanks in advance!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 21-Dec-2007 10:34:55   

The selected value should be bindied to the field that represent it from the main entity. (The FK).

eg. If we are displaying Orders in a GridView and there is a field for the CustomerId, but we want to display a dropdownList of Customer names in the Edit Mode, then the SelectedValue should be binded to the CustomerId of the Orders entity.

SelectedValue='<%# Bind("CustomerId") %>
Karim
User
Posts: 14
Joined: 17-Dec-2007
# Posted on: 21-Dec-2007 14:10:42   

Walaa wrote:

The selected value should be bindied to the field that represent it from the main entity. (The FK).

eg. If we are displaying Orders in a GridView and there is a field for the CustomerId, but we want to display a dropdownList of Customer names in the Edit Mode, then the SelectedValue should be binded to the CustomerId of the Orders entity.

SelectedValue='<%# Bind("CustomerId") %>

That is what i am trying to do, but there seems to be a problem if i have a Order.Id and Customer.Id. How can i distinguish between the two when i bind the selected value? (All decleratively)

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 21-Dec-2007 14:37:39   

You should bing to the FK field in the Order table that references the Customer.Id PK.

Please post the DDL of the database tables involved.

Karim
User
Posts: 14
Joined: 17-Dec-2007
# Posted on: 21-Dec-2007 22:56:40   

Walaa wrote:

You should bing to the FK field in the Order table that references the Customer.Id PK.

Please post the DDL of the database tables involved.

Sorry, i was mistaken. Maybe next time i should just really look more closely to what you are typing. simple_smile Thanks!