我正在嘗試使用我的listview的下拉列表來篩選結果。在ControlParameter'y'中找不到控件'x'
我已經改變了選擇查詢如下數據源...
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>
的下拉列表:
<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>
正確的控制名稱用於(在完全相同的大寫字母),但加載的頁面返回在ControlParameter'姓氏'中找不到控件'DropDownList1'。
有什麼我在做什麼錯誤的建議嗎?
編輯:這裏是堆棧跟蹤,如果有幫助
[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
「AccessDataSource」和「DropDownList」在不同的命名容器中嗎? –
它們位於同一頁面內的兩個不同的ContentPlaceHolders中。 – Imran
然後'ControlID'需要以'ContentPlaceHolder'的'ID'作爲前綴,其中包含'DropDownList':http://rockoverflow.com/a/5719348/124386 –