Hi,
I have a dropdownlist that has 2 options (Show new or Show old).
When users select 'Show new' and hit 'Search' button, it will show all new equipments.
When users select 'Show old' and hit 'Search' button, it will show all old equipments.
It works fine the way it is.
Now, I would like to add a third option called 'Show all'.
If users select 'ALL' then it will show both New and Old equipments.
This is where I am stuck.
I tried to modify my SQL query to add another criteria in the CASE statement that includes both OLD and NEW equipment but my query kept returning zero records.
There must be an easy way to do this but I don't know what.
Anyway, this is a portion of my code that is working fine for Option 1 (New) and Option 2 (Old).
aspx page
<asp:DropDownList ID="ddlEquipment" ruant="server">
<asp:ListItem Value = "2">Show All (New and Old)</asp:ListItem>
<asp:ListItem Value = "1">Show New</asp:ListItem>
<asp:ListItem Value = "0">Show Old</asp:ListItem>
</asp:DropDownList>
aspx.cs page
using (SqlCommand cmd = new SqlCommand("SELECT CAST(CASE WHEN Col1='New' AND Col2='New' THEN 1 ELSE 0 END AS bit) As Equipment_Status
FROM TableName WHERE CAST(CASE WHEN Col1='New' AND Col2='New' THEN 1 ELSE 0 END AS bit) = @ Equipment_Status, con));
{
con.Open();
cmd.Parameters.AddWithValue("Equipment_Status", ddlEquipment.SelectedValue.Trim());
Any help is greatly appreciated.