How Do I Set Decimal places in DataTable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.##}") %>
 
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
 
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.
 
I am doing this in Windows Form Grid (C# .NET)

Nicholas Paldino said:
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]
- (e-mail address removed)

Kunal Patel said:
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
 
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 said:
I am doing this in Windows Form Grid (C# .NET)

Nicholas Paldino said:
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]
- (e-mail address removed)

Kunal Patel said:
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




:

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.
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top