C# 找不到控件';x';在控制参数中';y';

C# 找不到控件';x';在控制参数中';y';,c#,asp.net,visual-studio-2010,ms-access,C#,Asp.net,Visual Studio 2010,Ms Access,我正在尝试使用我的listview的dropdownlist筛选结果 我对数据源的select查询进行了如下更改 列表视图: <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/ASPNetDB.mdb" SelectCommand="SELECT * FROM [tblNames] WHERE Surnames=@Surnames">

我正在尝试使用我的listview的dropdownlist筛选结果

我对数据源的select查询进行了如下更改

列表视图:

<asp:AccessDataSource ID="AccessDataSource1" runat="server" 
        DataFile="~/App_Data/ASPNetDB.mdb" 
        SelectCommand="SELECT * FROM [tblNames] WHERE Surnames=@Surnames">
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownList1" Name="Surnames" 
                PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:AccessDataSource>

ControlID
需要以包含下拉列表的
ContentPlaceHolder
的ID作为前缀:

<asp:ControlParameter 
   Name="Surnames" 
   ControlID="ContentPlaceholderID$DropDownList1" 
   PropertyName="SelectedValue" 
/>

此外,确保您的兴趣控制已在=“服务器”上运行。Argh.

访问数据源
DropDownList
是否在不同的命名容器中?它们在同一页面中的两个不同的ContentPlaceHolder中。然后
ControlID
需要以包含
DropDownList
ContentPlaceHolder的
ID
作为前缀:@RichardDeeming:你应该回答这个问题,你的答案是正确的。我发现如果控件嵌套在多个元素中,你必须全部指定它们,所以我最终得到了如下结果:YourContentPlaceHolder$YourASPxCallbackPanel$yourAspXPopControl$YourASPxComboBox
[InvalidOperationException: Could not find control 'DropDownList1' in ControlParameter 'Surname'.]
   System.Web.UI.WebControls.ControlParameter.Evaluate(HttpContext context, Control control) +2107838
   System.Web.UI.WebControls.Parameter.UpdateValue(HttpContext context, Control control) +50
   System.Web.UI.WebControls.ParameterCollection.UpdateValues(HttpContext context, Control control) +113
   System.Web.UI.WebControls.SqlDataSource.LoadCompleteEventHandler(Object sender, EventArgs e) +46
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Page.OnLoadComplete(EventArgs e) +9010786
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2350
<asp:ControlParameter 
   Name="Surnames" 
   ControlID="ContentPlaceholderID$DropDownList1" 
   PropertyName="SelectedValue" 
/>