Solved

Could not find control '' in ControlParameter ''.

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

791 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