Need help with nested GridView inside a Repeater.

Hi!  I have a repeater that is databound to a DataTable from the code behind.  Within this repeater is a GridView.  The Gridview is bound to an Object Data Source on the ASPX page.  The Object Data Source gets its Select parameter value from a HiddenField that is also within the Repeater.  

What I'm trying to do is this.  The repeater updates the value of the HiddenField (ID = hf_cc_PickTicketID) The Object Data Source needs the value to load the Grid with the appropriate data.  

When I view the page in a browser I get the following error:

Could not find control 'hf_cc_PickTicketID' in ControlParameter 'PickTicketID'.

The error points to Line 39

Line 37:
Line 38:         Repeater_CustomComponents.DataSource = dt
Line 39:         Repeater_CustomComponents.DataBind()Line 40:
 
Can someone tell me what I'm doing wrong and how I can fix this?
<asp:Repeater ID="Repeater_CustomComponents" runat="server">
        <ItemTemplate>
            <div id="itemHeader">
                SKU: <%# DataBinder.Eval(Container.DataItem, "ComponentID")%> | Quantity Ordered: <%# DataBinder.Eval(Container.DataItem, "Quantity")%>
            </div>
            <div id="itemContainer">
                <!-- HIDDEN FIELD:  Used by ODS to obtain the Select value parameter -->
                <asp:HiddenField ID="hf_cc_PickTicketID" runat="server" Value='<%# DataBinder.Eval(Container.DataItem, "PickTicketID")%>' />

                <div id="itemImage">
                    <img alt="Picture of <%# DataBinder.Eval(Container.DataItem, "ComponentID")%>" src="<%# DataBinder.Eval(Container.DataItem, "ImageURL")%>Thumbnail.jpg" />
                </div>
                <div id="itemProperties">
                    <asp:GridView ID="GridView1" runat="server" DataSourceID="ODS_Items">
                    </asp:GridView>
                </div>
                <div class="clear"></div>
            </div>
            <div id="itembreak">
                <hr />
            </div>
        </ItemTemplate>
    </asp:Repeater>

    <!-- Object Data Source -->
    <asp:ObjectDataSource ID="ODS_Items" runat="server" 
        SelectMethod="GetPickTicketItems" 
        TypeName="PickPackItemsBLL" 
        OldValuesParameterFormatString="original_{0}" >
    <SelectParameters>
        <asp:ControlParameter ControlID="hf_cc_PickTicketID" Name="PickTicketID" 
            PropertyName="Value" Type="Int32" />
    </SelectParameters>
    </asp:ObjectDataSource>

Open in new window

cdemott33Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John ClaesSenior .Net Consultant & Technical AnalistCommented:
because the controller is in a repeater the name is changed for that controller.
because that every repeateting Line otherwise gives the same Id for every occurance.
MlandaTCommented:
structurally, what you want to do cannot be. you have to use the Repeater controls ItemDataBound  event to set the datasource fro the grid.
Sub Repeater1_ItemDataBound(Sender As Object, e As RepeaterItemEventArgs)
        
        ' This event is raised for the header, the footer, separators, and items.
        ' Execute the following logic for Items and Alternating Items.

        If (e.Item.ItemType = ListItemType.Item) Or _
            (e.Item.ItemType = ListItemType.AlternatingItem) Then

              dim GridView1 as GridView = e.Item.FindControl("GridView1")
              if GridView1 isnot nothing then

                    GridView1.DataSource = 
                    GridView1.DataBind = functionGetPickTicketItems( CType(e.Item.DataItem, DataRowView)("PickTicketID"))

              end if

        End If

End Sub

Open in new window


where functionGetPickTicketItems is a function which takes in a single parameter, the PickTicketID and returns the appropriate datatype.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cdemott33Author Commented:
MlandaT - Thank you for your help, and more importantly, for provideing an example of how to solve my problem.  YOU are the reason I love the Expert Exchange.   Fast Help and GREAT WRITTEN examples of how I can solve my problem.  Keep up the great work!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.