I have an Sql Data Source with a field named Category which has values like category1, category 2 etc. I want a gridview where user has a choice to select valued in any category or a combination of categories for the filed Category.
for giving this choice to users, I have a dropdownlist with values category1 and category2 etc. My code for selecting a category is
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
if(CategoryDropdownList.SelectedValue = "Category1")
{
e.Command.Parameters["@Category"].Value = "category1";
}
else if (CategoryDropdownList.SelectedValue = "category2")
{
e.Command.Parameters["@Category"].Value = "category2";
}
}
This code works fine when selecting a value for a field Category.
Now I want to introduce a multiple selection choice for users whereby they can select more than one category
for example: if the dropdown list has an value category1or2, the selection of this value should give the user values from database where value of Category field is either category1 or ctegory2
I am not able to find the code for this kind of multiple choice of a parameter. I am also not sure whether it is possible to assign suck multiple values by use of 'OR' and 'AND' as we use in if statements.
Kindly advice me what course of action I should follow.
if this question sounds too elementary, kindly pardon me for asking and help me because I am still a beginner in ASP.NET. I am using C#.