title: How to pass an ID from a repeater row to a nested gridview?
body: <p><strong>QUESTION</strong></p>
  
  <p>If you have a gridview inside a repeater, how do you pass a primary key ID to the gridview where the primary key relates to the repeaters item template row?</p>
  
  <p>I am currently attempting to do this by using a hiddenfield that contains the PK and a control parameter to detect it and bind it to the gridview.</p>
  
  <p><strong>CURRENT ERROR</strong></p>
  
  <p>Could not find control 'hidPK' in ControlParameter 'PK'.</p>
  
  <p><strong>ABBREVIATED CODE</strong></p>
  
  <pre><code>&lt;asp:Repeater ID="rpt" RunAt="Server"&gt;
    &lt;ItemTemplate&gt;
      &lt;asp:HiddenField ID="hidPK" runat="server" Value='&lt;%# DataBinder.Eval(Container.DataItem, "PK") %&gt;'/&gt;
  
      &lt;asp:GridView ID="GV" DataSourceID="sqlSource"&gt;&lt;/asp:GridView&gt;
  
    &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  
  &lt;asp:SqlDataSource ID="sqlSource" RunAt="Server" SelectCommand="spPopulateGridview" SelectCommandType="StoredProcedure"&gt;
    &lt;SelectParameters&gt;
      &lt;asp:ControlParameter Type="Int32" Name="PK" DefaultValue="0" ControlID="hidPK"/&gt;
    &lt;/SelectParameters&gt;
  &lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p><strong>EDITS</strong></p>
  
  <pre><code>Protected Sub rpt_ItemDataBound(Sender As Object, e As RepeaterItemEventArgs) Handles rpt.ItemDataBound
      If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem  Then
          Dim gv As GridView = TryCast(e.Item.FindControl("GV"), GridView)    
          gv.DataSource = ds
          gv.DataBind()
      End If
  End Sub
  </code></pre>