Solved

Could not find control '' in ControlParameter ''.

Posted on 2006-06-13
4
2,667 Views
Last Modified: 2012-05-05
I am getting the error above when trying to reference a drop down list in a gridview, edititemtemplate section.

Here is the gridview containing the template
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="LocationsObjds"
                DataKeyNames="LocationID,LocationCategoryID" Width="782px" OnRowCommand="GridView1_RowCommand"
                OnRowUpdating="GridView1_RowUpdating">
                <Columns>
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
                    <asp:BoundField DataField="LocationID" HeaderText="LocationID" SortExpression="LocationID"
                        ReadOnly="True" Visible="False" />
                    <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
                    <asp:BoundField DataField="AddressIdentifier" HeaderText="AddressIdentifier" SortExpression="AddressIdentifier" />
                    <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
                    <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
                    <asp:BoundField DataField="County" HeaderText="County" SortExpression="County" />
                    <asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" />
                    <asp:BoundField DataField="ZipCode" HeaderText="ZipCode" SortExpression="ZipCode" />
                    <asp:BoundField DataField="LocationCategoryID" HeaderText="LocationCategoryID" SortExpression="LocationCategoryID"
                        Visible="False" />
                    <asp:TemplateField HeaderText="Type">
                        <ItemTemplate>
                            <asp:Label ID="lblLocationType" runat="server" Text='<%# Eval("LocationCategoryDescription") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="ddlLocationCategory" runat="server" DataSourceID="LocationCategoryObjds"
                                DataTextField="LocationCategoryDescription" DataValueField="LocationCategoryID">
                            </asp:DropDownList>
                        </EditItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>

and the datasource attempting to use its value
        <asp:ObjectDataSource ID="LocationsObjds" runat="server" DeleteMethod="DeleteForVendor"
            InsertMethod="InsertForVendor" SelectMethod="GetByVendorIDFromVendorLocations"
            TypeName="VendorManagement.BusinessLogicLayer.BLLWsLocationsProvider" UpdateMethod="Update"
            OldValuesParameterFormatString="original_{0}">
            <SelectParameters>
                <asp:SessionParameter Name="vendorID" SessionField="VendorID" Type="Int32" />
            </SelectParameters>
            <InsertParameters>
                <asp:SessionParameter Name="VendorID" SessionField="VendorID" Type="Int32" />
                <asp:Parameter Name="entity" Type="Object" />
            </InsertParameters>
            <DeleteParameters>
                <asp:SessionParameter Name="VendorID" SessionField="VendorID" Type="Int32" />
                <asp:Parameter Name="LocationID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="LocationID" Type="Int32" />
                <asp:Parameter Name="Address" Type="String" />
                <asp:Parameter Name="AddressIdentifier" Type="String" />
                <asp:Parameter Name="City" Type="String" />
                <asp:Parameter Name="State" Type="String" />
                <asp:Parameter Name="County" Type="String" />
                <asp:Parameter Name="ZipCode" Type="Int32" />
                <asp:Parameter Name="Country" Type="String" />
                <asp:ControlParameter ControlID="GridView1$ddlLocationCategory" Name="LocationCategoryID"
                    PropertyName="SelectedValue" Type="Int32" />
            </UpdateParameters>
        </asp:ObjectDataSource>

Note:
The controlID is set to "GridView1$ddlLocationCategory". I originally used "ddlLocationCategory" but it was recommended to use the control container name followed by a $ then the control name. I have heard this work for a number of people but it isn't happening for me.

Thoughts?
0
Comment
Question by:jason_lewis
  • 2
4 Comments
 
LVL 14

Expert Comment

by:existenz2
ID: 16900739
You need to iterate through the gridview items and then use FindControl("ddlLocationCategory"), that should work.
0
 
LVL 1

Author Comment

by:jason_lewis
ID: 16912569
I was attempting to do this only with the wizards and not have to right code.



0
 
LVL 1

Accepted Solution

by:
uiey earned 500 total points
ID: 16912684
You need to edit the template (edit item or insert item template), and add a drop down to your template.
Set the data-source of that drop-down to the lookup values table, retrieving all of the rows. Make sure the display is the the column you need shown in the drop down, and the value is the Fkey to the base table.
Set the data-bindings so that it starts with the value(FKey) from the base table, and make it 2 way.

You now have a drop down in your grid/details view that displays the contents of a lookup table for edit/insert only, and updates the correct key to your database.
0
 
LVL 1

Author Comment

by:jason_lewis
ID: 16915631
That works, thanks
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now