c#将所选值从dropdownlist传递到accessdatasource selectparameter
我有一个access数据源,它加载一个列表框值。我试图向accessdatasource传递一个参数,但我不确定我做错了什么c#将所选值从dropdownlist传递到accessdatasource selectparameter,c#,C#,我有一个access数据源,它加载一个列表框值。我试图向accessdatasource传递一个参数,但我不确定我做错了什么 <asp:DropDownList ID="customerName" runat="server"> <asp:ListItem value="69" Text="Danny"></asp:ListItem> <asp:ListItem value="23" Text="Sarah"></asp:Li
<asp:DropDownList ID="customerName" runat="server">
<asp:ListItem value="69" Text="Danny"></asp:ListItem>
<asp:ListItem value="23" Text="Sarah"></asp:ListItem>
</asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="/App_Data/data.mdb" SelectCommand="SELECT * FROM table WHERE customerID='?'">
<selectparameters>
<asp:ControlParameter Name="customerID" ControlID="customerName" PropertyName="SelectedValue" />
</selectparameters>
<asp:ListBox ID="lstCustomers" runat="server" AutoPostBack="True"
DataSourceID="AccessDataSource1" DataTextField="customerName"
DataValueField="customerID" Width="175px" Height="365px"
onselectedindexchanged="lstCustomers_SelectedIndexChanged"></asp:ListBox>
列表返回为空白。。。不知道我做错了什么 我只是想澄清一下。。Richard Deeming解决了这个问题,但没有答案。我会把代码贴在这里 它是通过删除?周围的单引号解决的?SQL中的参数
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="/App_Data/data.mdb" SelectCommand="SELECT * FROM table WHERE customerID=?">
参数占位符周围是否需要单引号?试试WHERE customerID=?
吧。这样就行了!非常感谢。