By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,307 Members | 2,071 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,307 IT Pros & Developers. It's quick & easy.

How to change a populated DataColumn UnderlyingSystemType (app)

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.