QUESTION
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?
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.
CURRENT ERROR
Could not find control 'hidPK' in ControlParameter 'PK'.
ABBREVIATED CODE
<asp:Repeater ID="rpt" RunAt="Server">
<ItemTemplate>
<asp:HiddenField ID="hidPK" runat="server" Value='<%# DataBinder.Eval(Container.DataItem, "PK") %>'/>
<asp:GridView ID="GV" DataSourceID="sqlSource"></asp:GridView>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="sqlSource" RunAt="Server" SelectCommand="spPopulateGridview" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter Type="Int32" Name="PK" DefaultValue="0" ControlID="hidPK"/>
</SelectParameters>
</asp:SqlDataSource>
EDITS
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