Solved

Could not find control '' in ControlParameter ''.

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

815 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

9 Experts available now in Live!

Get 1:1 Help Now