Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#将所选值从dropdownlist传递到accessdatasource selectparameter_C# - Fatal编程技术网

c#将所选值从dropdownlist传递到accessdatasource selectparameter

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

我有一个access数据源,它加载一个列表框值。我试图向accessdatasource传递一个参数,但我不确定我做错了什么

<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=?
吧。这样就行了!非常感谢。