Solved

Could not find control '' in ControlParameter ''.

Posted on 2006-06-13
4
2,668 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

15 Experts available now in Live!

Get 1:1 Help Now