Inv*_*tax 5 c# asp.net ms-access visual-studio-2010
我正在尝试使用listview的下拉列表来过滤结果.
我已经更改了数据源的选择查询,如下所示...
列表视图:
<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>
Run Code Online (Sandbox Code Playgroud)
下拉列表:
<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>
Run Code Online (Sandbox Code Playgroud)
使用正确的控件名称(完全相同的上限),但加载页面返回无法在ControlParameter'Surnames'中找到控件'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
Run Code Online (Sandbox Code Playgroud)
在ControlID
需要与的所述ID的前缀ContentPlaceHolder
含有DropDownList的:
<asp:ControlParameter
Name="Surnames"
ControlID="ContentPlaceholderID$DropDownList1"
PropertyName="SelectedValue"
/>
Run Code Online (Sandbox Code Playgroud)
另见:https://stackoverflow.com/a/5719348/124386
归档时间: |
|
查看次数: |
6906 次 |
最近记录: |