0

当值设置为 null 时,我有一个包含各种项目的下拉框我想使用控制参数选择多个项目来填充数据源,如下所示。这个选择命令不起作用,谁能帮我看看我做错了什么?编辑下面的代码现在是正确的和功能.....

<asp:DropDownList ID="FilterList1" runat="server">

                    <asp:ListItem  Selected="True" Value=" ">Produce</asp:ListItem>
                            <asp:ListItem>Fruits</asp:ListItem>
                            <asp:ListItem>Vegetables</asp:ListItem>
                            <asp:ListItem>Milk</asp:ListItem>
                            <asp:ListItem>Pop</asp:ListItem>

</asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" 
    DataFile="~/AFOLDER/db1.mdb" 
    SelectCommand="SELECT * FROM [Table1] WHERE IIF( (@Food1 ='  '), [Food] In ('Fruit','Vegetable'), (Food =@Food1) )">
    <SelectParameters>
      <asp:ControlParameter ControlID="FilterList1" Name="Food1" 
            PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
</asp:AccessDataSource>
4

1 回答 1

0

当您使用AccessDataSource1时,请尝试访问 SQLIIF()语句,例如:

SelectCommand="SELECT * FROM [Table1] WHERE (Service =@Service1) OR IIF((@Service1 ='  '), IIF( [Service] In ('In Service','Out of Service'), True, False), False)

另外,请确保您使用正确的语法@Service1 =' '(可能是@Service1 =''?)

希望这会有所帮助。

问候

于 2014-08-08T21:46:24.393 回答