The ManyToManyListRelationship control manages the junction table that links your primary entity with a foreign key table.
<asp:FormView ID="FormView1" runat="server" DataSourceID="CustomersDataSource" DefaultMode="Edit">
<EditItemTemplate>
<table border="0">
<tr>
<td>Cust #:</td>
<td><asp:Label
ID="CustomerIDLabel" runat="server" Text='<%# Bind("CustomerID")
%>' /></td>
</tr>
<tr>
<td>Company Name:</td>
<td><asp:TextBox
ID="CompanyNameTextBox" runat="server" Text='<%# Bind("CompanyName")
%>' /></td>
</tr>
<tr>
<td valign="top">Demographics:</td>
<td>
<!-- the visual representation of the many-to-many relationship -->
<asp:CheckBoxList ID="CustomerDemographicsList" runat="server"
DataSourceID="CustomerDemographicsDataSource"
DataTextField="CustomerDesc"
DataValueField="CustomerTypeID"
/>
<!-- provides the list of available data for the relationship -->
<data:EntityDataSource ID="CustomerDemographicsDataSource"
runat="server"
ProviderName="CustomerDemographicsProvider"
EntityTypeName="Northwind.BLL.CustomerDemographics, Northwind.BLL"
SelectMethod="GetAll"
Filter="CustomerDesc != 'Temporary'"
Sort="CustomerDesc ASC"
/>
<!-- provides management of the link table -->
<data:EntityDataSource ID="CustomerCustomerDemoDataSource"
runat="server"
ProviderName="CustomerCustomerDemoProvider"
EntityTypeName="Northwind.BLL.CustomerCustomerDemo, Northwind.BLL"
EntityKeyTypeName="System.String"
SelectMethod="GetByCustomerID"
>
<Parameters>
<asp:QueryStringParameter Name="EntityId"
QueryStringField="id" />
</Parameters>
</data:EntityDataSource>
<!--
The relationship controls hook one or more
EntityDataSource controls to the
EntityDataSource specified by the
PrimaryMember.EntityDataSourceID property.
This allows multiple insert/update operations
to be executed during a single
form submission.
--> <data:ManyToManyListRelationship ID="CustomerCustomerDemoRelationship" runat="server"> <%-- represents the Customers table --%> <PrimaryMember runat="server"
DataSourceID="CustomersDataSource"
EntityKeyName="CustomerID"
/> <%-- represents the CustomerCustomerDemo link table --%> <LinkMember runat="server"
DataSourceID="CustomerCustomerDemoDataSource"
EntityKeyName="CustomerID"
ForeignKeyName="CustomerTypeID"
/> <%-- represents the CustomerDemographics table --%> <ReferenceMember runat="server"
DataSourceID="CustomerDemographicsDataSource"
ListControlID="CustomerDemographicsList"
EntityKeyName="CustomerTypeID"
/>
</data:ManyToManyListRelationship> </td>
</tr>
</table>
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="UpdateButton"
runat="server" CausesValidation="True" CommandName="Update"
Text="Update" />
<asp:Button ID="CancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</FooterTemplate>
</asp:FormView>
<!-- primary entity data source --><data:EntityDataSource ID="CustomersDataSource" runat="server"
ProviderName="CustomersProvider"
EntityTypeName="Northwind.BLL.Customers, Northwind.BLL"
EntityKeyTypeName="System.String"
EntityKeyName="CustomerID"
SelectMethod="GetByCustomerID"
>
<Parameters>
<asp:QueryStringParameter Name="EntityId" QueryStringField="id" Type="String" />
</Parameters>
</data:EntityDataSource>
Bobby Diaz
------------------------------------------
Member of the .NetTiers team
http://www.nettiers.com
------------------------------------------