title: Gridviews inside Repeater
body: <p>I have a repeater on my page, linked with a datasource who fills the repeater with teams. My goal is to create a header for each team and a gridview for each team to modify the players in each team.</p>
  
  <p>Problem: the datasource of the gridview needs a PK of the team to get the appropriate players out of the database. How can I pass them?</p>
  
  <pre><code>&lt;asp:Repeater ID="Repeater1" runat="server" DataSourceID="odsTeam"&gt;
      &lt;ItemTemplate&gt;
          &lt;h1&gt;
              &lt;%# Eval("name") %&gt;
              with maximum of
              &lt;%# Eval("st_max") %&gt;
              players.&lt;/h1&gt;
  
          &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="participant_id"
              DataSourceID="odsParticipant"&gt;
              &lt;Columns&gt;
                  &lt;asp:BoundField DataField="participant_id" HeaderText="participant_id" InsertVisible="False"
                      ReadOnly="True" SortExpression="participant_id" /&gt;
                  &lt;asp:BoundField DataField="participant_category_id" HeaderText="participant_category_id"
                      SortExpression="participant_category_id" /&gt;
                  &lt;asp:BoundField DataField="team_id" HeaderText="team_id" SortExpression="team_id" /&gt;
                  &lt;asp:BoundField DataField="room_id" HeaderText="room_id" SortExpression="room_id" /&gt;
                  &lt;asp:BoundField DataField="delegation_id" HeaderText="delegation_id" SortExpression="delegation_id" /&gt;
                  &lt;asp:BoundField DataField="first_name" HeaderText="first_name" SortExpression="first_name" /&gt;
                  &lt;asp:BoundField DataField="last_name" HeaderText="last_name" SortExpression="last_name" /&gt;
                  &lt;asp:BoundField DataField="date_of_birth" HeaderText="date_of_birth" SortExpression="date_of_birth" /&gt;
                  &lt;asp:BoundField DataField="gender" HeaderText="gender" SortExpression="gender" /&gt;
                  &lt;asp:BoundField DataField="identification_number" HeaderText="identification_number"
                      SortExpression="identification_number" /&gt;
                  &lt;asp:BoundField DataField="photo_url" HeaderText="photo_url" SortExpression="photo_url" /&gt;
                  &lt;asp:BoundField DataField="squad_number" HeaderText="squad_number" SortExpression="squad_number" /&gt;
                  &lt;asp:BoundField DataField="length" HeaderText="length" SortExpression="length" /&gt;
                  &lt;asp:BoundField DataField="weight" HeaderText="weight" SortExpression="weight" /&gt;
              &lt;/Columns&gt;
          &lt;/asp:GridView&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  &lt;asp:ObjectDataSource ID="odsTeam" runat="server" OldValuesParameterFormatString="original_{0}"
      OnSelecting="odsTeam_Selecting" SelectMethod="GetTeamsByDelegationID" TypeName="TeamBLL"&gt;
      &lt;SelectParameters&gt;
          &lt;asp:Parameter Name="delegation_id" Type="Int32" /&gt;
      &lt;/SelectParameters&gt;
  &lt;/asp:ObjectDataSource&gt;
  
  &lt;asp:ObjectDataSource ID="odsParticipant" runat="server" DeleteMethod="Delete" InsertMethod="Insert"
              OldValuesParameterFormatString="original_{0}" SelectMethod="GetParticipantsByTeamID"
              TypeName="ERASTableAdapters.tbl_participantTableAdapter" 
      UpdateMethod="Update" onselecting="odsParticipant_Selecting"&gt;
              &lt;DeleteParameters&gt;
                  &lt;asp:Parameter Name="Original_participant_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="Original_participant_category_id" Type="String" /&gt;
                  &lt;asp:Parameter Name="Original_team_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="Original_room_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="Original_delegation_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="Original_first_name" Type="String" /&gt;
                  &lt;asp:Parameter Name="Original_last_name" Type="String" /&gt;
                  &lt;asp:Parameter Name="Original_date_of_birth" Type="DateTime" /&gt;
                  &lt;asp:Parameter Name="Original_gender" Type="String" /&gt;
                  &lt;asp:Parameter Name="Original_identification_number" Type="String" /&gt;
                  &lt;asp:Parameter Name="Original_photo_url" Type="String" /&gt;
                  &lt;asp:Parameter Name="Original_squad_number" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="Original_length" Type="Decimal" /&gt;
                  &lt;asp:Parameter Name="Original_weight" Type="Decimal" /&gt;
              &lt;/DeleteParameters&gt;
              &lt;UpdateParameters&gt;
                  &lt;asp:Parameter Name="participant_category_id" Type="String" /&gt;
                  &lt;asp:Parameter Name="team_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="room_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="delegation_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="first_name" Type="String" /&gt;
                  &lt;asp:Parameter Name="last_name" Type="String" /&gt;
                  &lt;asp:Parameter Name="date_of_birth" Type="DateTime" /&gt;
                  &lt;asp:Parameter Name="gender" Type="String" /&gt;
                  &lt;asp:Parameter Name="identification_number" Type="String" /&gt;
                  &lt;asp:Parameter Name="photo_url" Type="String" /&gt;
                  &lt;asp:Parameter Name="squad_number" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="length" Type="Decimal" /&gt;
                  &lt;asp:Parameter Name="weight" Type="Decimal" /&gt;
                  &lt;asp:Parameter Name="Original_participant_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="Original_participant_category_id" Type="String" /&gt;
                  &lt;asp:Parameter Name="Original_team_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="Original_room_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="Original_delegation_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="Original_first_name" Type="String" /&gt;
                  &lt;asp:Parameter Name="Original_last_name" Type="String" /&gt;
                  &lt;asp:Parameter Name="Original_date_of_birth" Type="DateTime" /&gt;
                  &lt;asp:Parameter Name="Original_gender" Type="String" /&gt;
                  &lt;asp:Parameter Name="Original_identification_number" Type="String" /&gt;
                  &lt;asp:Parameter Name="Original_photo_url" Type="String" /&gt;
                  &lt;asp:Parameter Name="Original_squad_number" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="Original_length" Type="Decimal" /&gt;
                  &lt;asp:Parameter Name="Original_weight" Type="Decimal" /&gt;
              &lt;/UpdateParameters&gt;
              &lt;SelectParameters&gt;
                  &lt;asp:Parameter Name="team_id" Type="Int32" /&gt;
              &lt;/SelectParameters&gt;
              &lt;InsertParameters&gt;
                  &lt;asp:Parameter Name="participant_category_id" Type="String" /&gt;
                  &lt;asp:Parameter Name="team_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="room_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="delegation_id" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="first_name" Type="String" /&gt;
                  &lt;asp:Parameter Name="last_name" Type="String" /&gt;
                  &lt;asp:Parameter Name="date_of_birth" Type="DateTime" /&gt;
                  &lt;asp:Parameter Name="gender" Type="String" /&gt;
                  &lt;asp:Parameter Name="identification_number" Type="String" /&gt;
                  &lt;asp:Parameter Name="photo_url" Type="String" /&gt;
                  &lt;asp:Parameter Name="squad_number" Type="Int32" /&gt;
                  &lt;asp:Parameter Name="length" Type="Decimal" /&gt;
                  &lt;asp:Parameter Name="weight" Type="Decimal" /&gt;
              &lt;/InsertParameters&gt;
          &lt;/asp:ObjectDataSource&gt;
  </code></pre>