473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How Do I Set Decimal places in DataTable

I have a DataTable with Column DataType as Double I just want to show data in
C# datagrid with two decimal places

which property do I set for DataColum of DataTable and How?

Thanks

Nov 1 '07 #1
5 19145
Hi,

You do not modify the datatable, you do modify the way you display the info.

I use the line below in a similar escenario just to display a double with
two decimal positions inside a grid

<%#Eval("FirstYearComission", "{0:0.##}") %>

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Kunal Patel" <Kunal Pa***@discussions.microsoft.comwrote in message
news:16**********************************@microsof t.com...
>I have a DataTable with Column DataType as Double I just want to show data
in
C# datagrid with two decimal places

which property do I set for DataColum of DataTable and How?

Thanks

Nov 1 '07 #2
where do i assign this expression to mean which property of Datacolumn
can you please give me the general statment

i have following code with me

m_dataTable = new DataTable(m_strTableName);
DataColumn dc;
dc = m_dataTable.Columns.Add(COL_DEPTH,typeof(Double));
dc.DefaultValue = 0.00; dc.Caption = COL_DEPTH + " (ft)";

if i Want to set COL_DEPTH to 2 decimal places which property of
Datacolumn variable 'dc' shall i set
Also in above code i have set the Column Caption, in the Constructor, but
it doens show up in DataGrid Datagrid, it just shows the Column Name. How do
i make Column Caption Visible instead of Column Name in DataGrid


"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

You do not modify the datatable, you do modify the way you display the info.

I use the line below in a similar escenario just to display a double with
two decimal positions inside a grid

<%#Eval("FirstYearComission", "{0:0.##}") %>

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Kunal Patel" <Kunal Pa***@discussions.microsoft.comwrote in message
news:16**********************************@microsof t.com...
I have a DataTable with Column DataType as Double I just want to show data
in
C# datagrid with two decimal places

which property do I set for DataColum of DataTable and How?

Thanks


Nov 1 '07 #3
Kunal,

First, are you doing this in an ASP.NET grid, or a Windows Forms grid?
That's going to make a difference.

Regardless, you will not be setting the property on the
DataTable/DataColumn itself, as those deal with the data, not the display of
data.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kunal Patel" <Ku********@discussions.microsoft.comwrote in message
news:08**********************************@microsof t.com...
where do i assign this expression to mean which property of Datacolumn
can you please give me the general statment

i have following code with me

m_dataTable = new DataTable(m_strTableName);
DataColumn dc;
dc = m_dataTable.Columns.Add(COL_DEPTH,typeof(Double));
dc.DefaultValue = 0.00; dc.Caption = COL_DEPTH + " (ft)";

if i Want to set COL_DEPTH to 2 decimal places which property of
Datacolumn variable 'dc' shall i set
Also in above code i have set the Column Caption, in the Constructor, but
it doens show up in DataGrid Datagrid, it just shows the Column Name. How
do
i make Column Caption Visible instead of Column Name in DataGrid


"Ignacio Machin ( .NET/ C# MVP )" wrote:
>Hi,

You do not modify the datatable, you do modify the way you display the
info.

I use the line below in a similar escenario just to display a double with
two decimal positions inside a grid

<%#Eval("FirstYearComission", "{0:0.##}") %>

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Kunal Patel" <Kunal Pa***@discussions.microsoft.comwrote in message
news:16**********************************@microso ft.com...
>I have a DataTable with Column DataType as Double I just want to show
data
in
C# datagrid with two decimal places

which property do I set for DataColum of DataTable and How?

Thanks



Nov 1 '07 #4
I am doing this in Windows Form Grid (C# .NET)

"Nicholas Paldino [.NET/C# MVP]" wrote:
Kunal,

First, are you doing this in an ASP.NET grid, or a Windows Forms grid?
That's going to make a difference.

Regardless, you will not be setting the property on the
DataTable/DataColumn itself, as those deal with the data, not the display of
data.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kunal Patel" <Ku********@discussions.microsoft.comwrote in message
news:08**********************************@microsof t.com...
where do i assign this expression to mean which property of Datacolumn
can you please give me the general statment

i have following code with me

m_dataTable = new DataTable(m_strTableName);
DataColumn dc;
dc = m_dataTable.Columns.Add(COL_DEPTH,typeof(Double));
dc.DefaultValue = 0.00; dc.Caption = COL_DEPTH + " (ft)";

if i Want to set COL_DEPTH to 2 decimal places which property of
Datacolumn variable 'dc' shall i set
Also in above code i have set the Column Caption, in the Constructor, but
it doens show up in DataGrid Datagrid, it just shows the Column Name. How
do
i make Column Caption Visible instead of Column Name in DataGrid


"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

You do not modify the datatable, you do modify the way you display the
info.

I use the line below in a similar escenario just to display a double with
two decimal positions inside a grid

<%#Eval("FirstYearComission", "{0:0.##}") %>

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Kunal Patel" <Kunal Pa***@discussions.microsoft.comwrote in message
news:16**********************************@microsof t.com...
I have a DataTable with Column DataType as Double I just want to show
data
in
C# datagrid with two decimal places

which property do I set for DataColum of DataTable and How?

Thanks



Nov 1 '07 #5
Can any body pls help me out in this. How do i display double value up to
specified decimal places in the datagrid my datasurce is DataTable (C# .NET).
Which property of DataColumn shall i set and how?

"Kunal Patel" wrote:
I am doing this in Windows Form Grid (C# .NET)

"Nicholas Paldino [.NET/C# MVP]" wrote:
Kunal,

First, are you doing this in an ASP.NET grid, or a Windows Forms grid?
That's going to make a difference.

Regardless, you will not be setting the property on the
DataTable/DataColumn itself, as those deal with the data, not the display of
data.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kunal Patel" <Ku********@discussions.microsoft.comwrote in message
news:08**********************************@microsof t.com...
where do i assign this expression to mean which property of Datacolumn
can you please give me the general statment
>
i have following code with me
>
m_dataTable = new DataTable(m_strTableName);
DataColumn dc;
dc = m_dataTable.Columns.Add(COL_DEPTH,typeof(Double));
dc.DefaultValue = 0.00; dc.Caption = COL_DEPTH + " (ft)";
>
if i Want to set COL_DEPTH to 2 decimal places which property of
Datacolumn variable 'dc' shall i set
Also in above code i have set the Column Caption, in the Constructor, but
it doens show up in DataGrid Datagrid, it just shows the Column Name. How
do
i make Column Caption Visible instead of Column Name in DataGrid
>
>
>
>
"Ignacio Machin ( .NET/ C# MVP )" wrote:
>
>Hi,
>>
>You do not modify the datatable, you do modify the way you display the
>info.
>>
>I use the line below in a similar escenario just to display a double with
>two decimal positions inside a grid
>>
><%#Eval("FirstYearComission", "{0:0.##}") %>
>>
>--
>Ignacio Machin
>http://www.laceupsolutions.com
>Mobile & warehouse Solutions.
>"Kunal Patel" <Kunal Pa***@discussions.microsoft.comwrote in message
>news:16**********************************@microso ft.com...
>I have a DataTable with Column DataType as Double I just want to show
>data
>in
C# datagrid with two decimal places
>
which property do I set for DataColum of DataTable and How?
>
Thanks
>
>>
>>
>>
Nov 2 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
3
by: Brent Bortnick | last post by:
Does anyone know how to find out the number of decimal places a number has. I need this info so that i can round to 3 decimal places if the number has 3 decimal places or to 2 decimal places if...
2
by: Carl G | last post by:
I am storing a 0.000 a System.Decimal in a DataRow. On retrieval the value is only 0 without the three decimal places. It looks like the Get property returns System.Decimal.Zero, but why???? I...
4
by: italia | last post by:
I changed the Fieldsize Property from text to Long Integer and Decimal Places = 6. I had decimals in the original field. But after the transfer, the digits after the decimals are gone. Now...
8
by: nick | last post by:
printf("%lf",3.25); the result is 3.25000 i want the answer correct to 3 decimal places What should i do? thanks!
3
by: mohaaron | last post by:
Hello All, Does anyone know of a way to test a decimal for the number of places it has before and after the decimal? I need to do something like this. decimal value1 = 172.45; // If value1...
19
by: VK | last post by:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/ b495b4898808fde0> is more than one month old - this may pose problem for posting over some news servers. This is why I'm...
2
by: hunslair | last post by:
This is a really basic question. I am taking a teach yourself beginners course on Access 2003 and have run into a road block on one practice. In a select query, I have created a simple calculation...
3
by: David | last post by:
Any ideas why this statement: mBalanceChange = Double.Parse(strCurrentBalance, Globalization.NumberStyles.AllowThousands Or Globalization.NumberStyles.AllowDecimalPoint) - mBalanceDouble ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
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,...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.