dataview rowfiltering question

  • Thread starter Thread starter Aniket Sule
  • Start date Start date
A

Aniket Sule

Hi,
I am trying to put a filter on a dataview. the column has [] in its name, it
is called - tml.[TYPE_CHAR]
i tried escaping the column name as per the MSDN help - [tml.[TYPE_CHR\]]
However i get a compilre error - "unrecognised escape sequence"
Can anyone point out what I'm doing wrong ??

Thanks
Aniket

the code is -
private const string TML_TYPE_COL = "[tml.[TYPE_CHR\]]";
string Filter = TML_TYPE_COL + " ='Active' ";
_dataView.RowFilter = Filter;
 
Aniket said:
Hi,
I am trying to put a filter on a dataview. the column has [] in its
name, it is called - tml.[TYPE_CHAR]
i tried escaping the column name as per the MSDN help -
[tml.[TYPE_CHR\]] However i get a compilre error - "unrecognised
escape sequence"
Can anyone point out what I'm doing wrong ??

If you have access to the database, I'd recommend changing the field
name. Otherwise, have you tried @"tml.[TYPE_CHAR]"?

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
I tried using @"tml.[TYPE_CHR]", which throws an error saying "Cannot locate
column tml.TYPE_CHR". Its getting rid of the [] while trying to look for the
column for some reason.
I could access teh underlying dataset column and change the column name if
none of this works, but i was hoping to avoid that.

Thanks for the help
Aniket

Frank Oquendo said:
Aniket said:
Hi,
I am trying to put a filter on a dataview. the column has [] in its
name, it is called - tml.[TYPE_CHAR]
i tried escaping the column name as per the MSDN help -
[tml.[TYPE_CHR\]] However i get a compilre error - "unrecognised
escape sequence"
Can anyone point out what I'm doing wrong ??

If you have access to the database, I'd recommend changing the field
name. Otherwise, have you tried @"tml.[TYPE_CHAR]"?

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
Hi,

You can try to trick the system by defining the square brackets by their
numerical codes in a form of \0xnnnn. You can also try to double the both
square brackets (that is, [[TYPE_CHR]]). The best advice would be to refer
to the MSDN docs on the DataColumn.Expression property syntax, there's a
chance such issues are explained there.
 
Back
Top