469,631 Members | 1,476 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

How to change a populated DataColumn UnderlyingSystemType (app)

I have a datagrid with one column that is boolean (it is a checkbox column).
So that myDataTable.Column["myColName"]..DataType.UnderlyingSystemType ==
System.Boolean. For printing purposes, I would like to change this from a
boolean to a string, so that I may manipulate the output to read "X" instead
of true, and "" for false. If I attempt to change the DataColumn type
currently, I get an error stating that I cannot change the type of a column
when it has already been populated.

So, how can I convert the column type, with data in it, from boolean to
string, so that I can change all "true" to "X" and all "false" to ""?

Oh, and this is a windows application, not asp.net...if it matters in this
case.

TIA
-John E.
Nov 16 '05 #1
1 3262
John E.

Why would you do this? If you are printing the information, then I
would think that you are performing the operations to print yourself. When
rendering the data in that column, just perform a transformation at that
point.

How is it that you are printing the data?

Another option would be to hide the column, and add a new column that
has an expression where the text is X if it is true, a space if it is false
(the value in the corresponding column for that row). Check the Expression
property of the DataColumn class for more information on this.

Hope this helps.

"John E." <pl*********@newsgroup.thanks> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have a datagrid with one column that is boolean (it is a checkbox
column).
So that myDataTable.Column["myColName"]..DataType.UnderlyingSystemType ==
System.Boolean. For printing purposes, I would like to change this from a
boolean to a string, so that I may manipulate the output to read "X"
instead
of true, and "" for false. If I attempt to change the DataColumn type
currently, I get an error stating that I cannot change the type of a
column
when it has already been populated.

So, how can I convert the column type, with data in it, from boolean to
string, so that I can change all "true" to "X" and all "false" to ""?

Oh, and this is a windows application, not asp.net...if it matters in this
case.

TIA
-John E.

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Miguel Dias Moura | last post: by
3 posts views Thread by Ken McCrory | last post: by
3 posts views Thread by DaveP | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.