C# correct syntax in sql string when filtering for a text field from a dropdownlist
Posted on 2012-08-28
I have a gridview and a drop down list. When a selection is made from the list, I want to filter the grid. I need to filter based on the selection from a drop down list. The value selected is a text field. I need the correct syntax for the sql statemtn in the c# code behind. What am I missing?
Here is my sql string. The Comp1 and Comp2 fields are text fields.
string strTransactions = "select * FROM vwTransactionsByComp where Comp1 = " + ddlComp.SelectedValue + " OR Comp2 = " + ddlComp.SelectedValue;