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

Convertig Problem Double.Parse

Hello !

I have an asp.net-datagrid.

On the itemdatabound-event I want to check a column.

Values of the columns are e.g.

153,57 €
200,10 €
n. def. (not defined, because of division 0)
20,33 €

I want to convert the cell-value to a double value:

double.parse don´t work because of the "€" or "n. def".

An exception is the consequence.

Do you have any idea ?

Thanks
aapaul

Mar 1 '06 #1
5 989
why not simply check the value first, you say you are already in the
ItemDataBound event, what do you currently have?

--
http://www.openmymind.net/

<lv****@gmx.net> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
Hello !

I have an asp.net-datagrid.

On the itemdatabound-event I want to check a column.

Values of the columns are e.g.

153,57 ?
200,10 ?
n. def. (not defined, because of division 0)
20,33 ?

I want to convert the cell-value to a double value:

double.parse don´t work because of the "?" or "n. def".

An exception is the consequence.

Do you have any idea ?

Thanks
aapaul
Mar 1 '06 #2
Depending on the value, I want to set the background color.

Paul

Mar 1 '06 #3
In the ItemDataBound event, do something like:

If (e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem) Then
dim dv as DataRowView = ctype(e.Item.DataItem, DataRowView)
if (dv("SomeValue") = "n") then
e.Item.Background = Color.Red
end if
End If
Here I'm casting DataItem to a DataRowView which assums you are binding to a
dataset/datatable or data view...you can use DataBinder.Eval() instead..

KArl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
<lv****@gmx.net> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
Depending on the value, I want to set the background color.

Paul

Mar 1 '06 #4
Thanks KArl !

I want to check if
dv("SomeValue") < 0 (then backcolor red)

dv could be e.g.

204.34 €
n. def.
400,12 €

double.parse makes an exception if it isnt a real number !

Do I have to build a function with try catch ?

Paul

Mar 1 '06 #5
There are a number of ways, a function that catches certain exceptions is
certainly a way to go....probably the way I'd go

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
<lv****@gmx.net> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Thanks KArl !

I want to check if
dv("SomeValue") < 0 (then backcolor red)

dv could be e.g.

204.34 ?
n. def.
400,12 ?

double.parse makes an exception if it isnt a real number !

Do I have to build a function with try catch ?

Paul
Mar 1 '06 #6

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

Similar topics

4
by: Jesper Denmark | last post by:
Hi, I use the double.Parse functionality to convert a number in a text file into a double. However, while this works fine on one computer it doesn't on another. I've found out that it is...
2
by: Rod Brick | last post by:
I'm trying to print a Double in straight decimal form, not exponential. I can't seem to accomplish this. This seems like it should be simple enough. The output I'm looking for is "0.00001", not...
5
by: Adam Klobukowski | last post by:
Hello I need to convert some strings int doubles. Unfortunetly strings do not follow my country culture standarts (we use , to separate decimal from fraction, but strings use . there etc.). ...
5
by: Markus Kling | last post by:
"double.Parse(double.MaxValue.ToString())" yields the following Exception: Value was either too large or too small for a Double. at System.Number.ParseDouble(String value, NumberStyles options,...
4
by: Daniel Walzenbach | last post by:
Hi, I wonder if somebody could explain me the difference between Double.Parse and Convert.ToDouble. If I'm not mistaken they are implemented differently (I though for a moment they might be the same...
2
by: Samuel R. Neff | last post by:
I'm using a quasi open-source project and am running into an exception in double.Parse which is effectively this: double.Parse(double.MinValue.ToString()) System.OverflowException: Value was...
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
2
by: Mika M | last post by:
Hi, Just for fun I'm trying to parse my GPS position string using C# 2005. When my code is trying to parse latitude string to double value like... double.Parse(items); // items = "6215.1058"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
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...

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.