473,326 Members | 2,732 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,326 software developers and data experts.

DataFormatString

Hi,

I have to display a double like this one 1.3234546 and this 2.0000.
If the double is like the first one then I only want to display 1.32.

This works with {0:F2}.

But with the second one I like to display 2. Not 2.00.

How can I do this?

Thanks!
Dec 6 '05 #1
1 3917
Well.... if you assing 2.0000000000 to a double, it will automatically
become 2, since there is no further precision required. you could solve
it with this:

Double dbl = 2.000000000000000000000;

if (dbl = Math.Floor(dbl))
{
return Convert.ToString(dbl) + ".00";
}

Dec 6 '05 #2

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

Similar topics

1
by: Jac | last post by:
Hey, I do a databinding and use the following <asp:datagrid .....> .... <asp:BoundColumn DataField="f1" HeaderText... DataFormatString="{0:d}">.. This works fine for a date. Now, I have...
1
by: frank | last post by:
I am using the DataFormatString property on BoundColumn objects in a DataGrid, but they don't seem to work for some reason. I copied them straight from another DataGrid where they work fine, but...
9
by: Roy | last post by:
Hey all, Ok, I have a boundcolumn in a datagrid which displays a smalldatetime field from a table. Behold: <asp:BoundColumn DataField="final_appvl_dt" SortExpression="final_appvl_dt"...
0
by: .Net Sports | last post by:
I'm trying to display a figure in my datagrid as a currency ($100.00), but I can't use DataFormatString inside templatecolumn, itemstyle, or itemtemplate (as they imply that no attribute named...
3
by: Gerhard Pretorius | last post by:
Since installing the VS.NET August CTP the DataFormatString of the BoundField in the Gridview does not work. Runtime v2.0.50727. <asp:BoundField DataField="Event_Date"...
1
by: Gerhard Pretorius | last post by:
I am reposting this..hoping someone (from Microsoft) can confirm this at least as a problem: Since installing the VS.NET August CTP the DataFormatString of the BoundField in the Gridview and...
1
by: Randall Parker | last post by:
In ASP.Net v1.1 and C# suppose one has: protected System.Web.UI.WebControls.DataGrid MyGrid; In Page_Load I want to do the equivalent of: MyGrid.Columns.DataFormatString="{0:d}"; or ...
1
by: Hardy Wang | last post by:
Hi, I have a GridView control in my web form (ASP.NET 2.0) <asp:GridView ID="gvReport" runat="server" AllowSorting="True" AutoGenerateColumns="False" Width="100%"> <HeaderStyle...
2
by: Rob Roberts | last post by:
I have a GridView that is bound to a collection of DateTimes (i.e. - Collection<DateTime>). I have a BoundField in the GridView, and its DataField is set to the DateTime's Date property, and the...
5
by: Tim Mackey | last post by:
hi, with a derived DataGrid control, i can override the CreateColumnSet method and scan into the DataGridColumns and set the DataFormatString, e.g. leave out the time part of a DateTime value. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.