My table has three columns(NIGHTS
,CRUISE-ID
,DEP-DATE
).I found a way to filter data table like this.(this link help a lot :Helpful).
DataView dv = new DataView(table);
dv.RowFilter = "NIGHTS=7";//query
this works fine and filtered data correctly.but when I use to filter like below
DataView dv = new DataView(table);
dv.RowFilter = "CRUISE-ID=2K2KFJDKF"; //query
It only reads CRUISE
string from the query
and gives an error.How can I filtered for CRUISE-ID
.hope your help.
From http://www.csharp-examples.net/dataview-rowfilter
Column names
If a column name contains any of these special characters ~ ( ) # \ / = > < + - * % & | ^ ' " [ ], you must enclose the column name within square brackets [ ]. If a column name contains right bracket ] or backslash \, escape it with backslash (] or \).
Thus the code would be:
dv.RowFilter = "[CRUISE-ID]='2K2KFJDKF'"; //query