[英]How can I use a case statement with a Drop Box? Access Database
當值設置為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>
在使用AccessDataSource1
,請嘗試使用Access SQL IIF()
語句,例如:
SelectCommand="SELECT * FROM [Table1] WHERE (Service =@Service1) OR IIF((@Service1 =' '), IIF( [Service] In ('In Service','Out of Service'), True, False), False)
另外,請確保使用正確的語法@Service1 =' '
(可能是@Service1 =''
?)
希望這會有所幫助。
問候
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.