Click here to Skip to main content
13,097,012 members (70,489 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hey guys.

1. I've created a Own Class, called "Text" (in my namespace "Data.Core").

2. I've created a DataTable-Object called "oDataTable".

3. I've Added a Column to this Object by using the following Code:

oDataTable.Columns.Add("Deutsch", typeof(Data.Core.Text));

4. I've created several DataRows to this DataTable-Object, which contains Text-Objects

4. I've set the DataTable to the ItemSource of a DataGrid (WPF .Net 4.0) and Bound a String-Property of my Text-Object to display in my Grid.

5. No I want to set a Filter. My First Idea was using the RowFilter-Property of my
DataTables DefaultView-Property. But there appears an EvaluateException:
"Can't convert Data.Core.Text into System.String".
Is there a common way to handle this problem or have I to create a workaround ?
Posted 29-Sep-11 21:28pm
Updated 29-Sep-11 22:04pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Supply your class with a implicit conversion operator for System.String, see Using Conversion Operators[^] for an explanation.
Jeff.Jefferson 11-Oct-11 2:38am
That really works ?

I've put these code in my "Text"-Class.
<pre lang="c#">
public static implicit operator string(Text t)
return t.Caption;

Caption is a string-Property of my Text-Class.

The same Error occurs :-S

But i have a question to the Conversion operators....

Can there occur a conflict by implement this Conversion for Strings and a "override ToString()-Method" ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 30 Sep 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100