0
我有访问数据源加载列表框值。我试图传递一个参数到accessdatasource,但我不知道我做错了什么。c#将下拉列表中的选定值传递给accessdatasource selectparameter
<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>
该列表返回为空......不知道我在做什么错了!
您是否需要围绕参数占位符的单引号?改为尝试'WHERE customerID =?'。 –
这是工作!谢谢 –