Tôi đang cố gắng lọc kết quả bằng cách sử dụng danh sách thả xuống cho chế độ xem danh sách của tôi.Không thể tìm thấy điều khiển 'x' trong ControlParameter 'y'
Tôi đã thay đổi các truy vấn chọn cho nguồn dữ liệu như sau ...
Các listview:
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/ASPNetDB.mdb"
SelectCommand="SELECT * FROM [tblNames] WHERE [email protected]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="Surnames"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:AccessDataSource>
Các DropDownList:
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="AccessDataSource2" DataTextField="Genre"
DataValueField="NameID" AppendDataBoundItems="true">
<asp:ListItem Value="" Selected ="True" >All Surnames</asp:ListItem>
</asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource2" runat="server"
DataFile="~/App_Data/ASPNetDB.mdb" SelectCommand="SELECT * FROM [tblSurnames]">
</asp:AccessDataSource>
Tên kiểm soát chính xác được sử dụng (các chính xác cùng một mũ là tốt), nhưng trang trên tải trả về Không thể tìm thấy kiểm soát 'DropDownList1' trong ControlParameter 'Surnames'.
Bất kỳ đề xuất nào về những gì tôi đang làm sai ở đây?
EDIT: Đây là stack trace nếu nó giúp
[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
Có phải 'AccessDataSource' và' DropDownList' trong các vùng chứa đặt tên khác nhau không? –
Chúng nằm trong hai ContentPlaceHolders khác nhau trong cùng một trang. – Imran
Sau đó, 'ControlID' cần được bắt đầu bằng' ID' của 'ContentPlaceHolder' chứa' DropDownList': http://stackoverflow.com/a/5719348/124386 –