Is there anyway to format a calculated datacolumn? I would like the
following column to display as money (formatted as $#,##0.00). Or how about
simply displaying the column formatted as a number with only 2 decimals
(#,##0.00)?
In the sample below, amount and taxrate are existing DataColumn's.
DataColumn colTax = new DataColumn();
colTax.DataType = System.Type.GetType("System.String");
colTax.ColumnName = "tax";
myTable.Columns.Add(colTax);
colTax.Expression = "String.Format(\"{0:C}\",\"amount*taxrate\" )"; //error
: Expression does not support String.Format 3 18625
Hi,
I think the burden of formatting should be put on a presentation tier code
(e.g. the DataGrid control) and not on a DataColumn - it's just not made to
be formattable by itself.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"J" <j> wrote in message news:vn************@corp.supernews.com... Is there anyway to format a calculated datacolumn? I would like the following column to display as money (formatted as $#,##0.00). Or how
about simply displaying the column formatted as a number with only 2 decimals (#,##0.00)? In the sample below, amount and taxrate are existing DataColumn's.
DataColumn colTax = new DataColumn(); colTax.DataType = System.Type.GetType("System.String"); colTax.ColumnName = "tax"; myTable.Columns.Add(colTax); colTax.Expression = "String.Format(\"{0:C}\",\"amount*taxrate\" )";
//error : Expression does not support String.Format
The example was formatting as currency, but the principal applies to
unlimited situations.
Don't think of it as formatting for the presentation layer, think of it as
building calculated datacolumns that require use of procedures, functions,
classes, whatever. To build any kind of calculated datacolumn, except for
the most simple, requires this functionality.
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:Ot**************@TK2MSFTNGP11.phx.gbl... Hi,
I think the burden of formatting should be put on a presentation tier code (e.g. the DataGrid control) and not on a DataColumn - it's just not made
to be formattable by itself.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx Bring the power of unit testing to VS .NET IDE
"J" <j> wrote in message news:vn************@corp.supernews.com... Is there anyway to format a calculated datacolumn? I would like the following column to display as money (formatted as $#,##0.00). Or how about simply displaying the column formatted as a number with only 2 decimals (#,##0.00)? In the sample below, amount and taxrate are existing DataColumn's.
DataColumn colTax = new DataColumn(); colTax.DataType = System.Type.GetType("System.String"); colTax.ColumnName = "tax"; myTable.Columns.Add(colTax); colTax.Expression = "String.Format(\"{0:C}\",\"amount*taxrate\" )"; //error : Expression does not support String.Format
This seem to be limited by the allowed syntax in the Expression property
(please refer to the "DataColumn.Expression Property" topic in MSDN), which
resembles SQL and has no support for calling managed code.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"J" <j> wrote in message news:vo************@corp.supernews.com... The example was formatting as currency, but the principal applies to unlimited situations. Don't think of it as formatting for the presentation layer, think of it as building calculated datacolumns that require use of procedures, functions, classes, whatever. To build any kind of calculated datacolumn, except
for the most simple, requires this functionality.
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:Ot**************@TK2MSFTNGP11.phx.gbl... Hi,
I think the burden of formatting should be put on a presentation tier
code (e.g. the DataGrid control) and not on a DataColumn - it's just not made to be formattable by itself.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx Bring the power of unit testing to VS .NET IDE
"J" <j> wrote in message news:vn************@corp.supernews.com... Is there anyway to format a calculated datacolumn? I would like the following column to display as money (formatted as $#,##0.00). Or how about simply displaying the column formatted as a number with only 2
decimals (#,##0.00)? In the sample below, amount and taxrate are existing DataColumn's.
DataColumn colTax = new DataColumn(); colTax.DataType = System.Type.GetType("System.String"); colTax.ColumnName = "tax"; myTable.Columns.Add(colTax); colTax.Expression = "String.Format(\"{0:C}\",\"amount*taxrate\" )"; //error : Expression does not support String.Format
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: J |
last post by:
Is there anyway to format a calculated datacolumn? I would like the
following column to display as money (formatted as $#,##0.00). Or how about
simply displaying the column formatted as a number...
|
by: Rui Rosa Mendes |
last post by:
I need a Round function, in Expression Syntax.
- Is there any not documented?
- Can I associate one?
Thanks.
Rui
rrm@medialog.pt
|
by: Dde |
last post by:
Hi everybody,
I have a problem with the "IN" operator in a datacolumn expression. I have a
datatable on which the following expression works:
mycode = '05'
but the following does not work:...
|
by: Vai2000 |
last post by:
Hi All, I have a dataColumn type of string which has values in form of range
like 0-80 or sometimes just 1 value like 100. I want to add another
column which basically computes the count of the...
|
by: Jason |
last post by:
First off, I tried to find an ADO.NET forum, or even just
a .NET framework forum but couldn't seem to locate one and
I apologize in advance if I've posted in the wrong place.
Because I'm using a...
|
by: Matt F |
last post by:
I'm trying to do something that seems like it should be pretty simple, but
haven't found a solution. I am trying to add a datacolumn to a datatable
that adds or subtracts a number of days based on...
|
by: shark |
last post by:
Hi
Is it any way to use current column value in Expression for this column.
Let say we want to have:
DataColumn2.Expression = IIF(DataColumn1 <0, DataColumn1, DataColumn2)
Its'n valid but how...
|
by: SMH |
last post by:
Hi All,
I am currently learning .Net 2, studying for 70-528. I've hit a bit of
a brick wall with DataColumn.Expression. As I understand it, this can
be used to (For example) concatenate two...
|
by: jelling |
last post by:
Hi,
Is it possible to use a CASE or IF ELSE statement in a datacolumn
expression?
Here's what I've tried:
'standardCodeColumn.Expression = "CASE StandardsBodyID
WHEN 1 THEN 'JCAHO' ELSE...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |