arun

arun

  • NA
  • 6
  • 0

Missing decimal point when trying to get value from a datatable : urgent

Jan 25 2007 8:28 AM
Hi All,

          I am reading a notepad file with 'Double' datatype data using string reader. I read the whole file as dataset and displayed it in a datagridview. 

   Ex. Data in the notepad file looks like:

            2.56441   -1.53248  -99.99869  -0.525618     0.268420   0.807265
            4.95127   -0.47233  -98.80724  -0.520184     0.267370   0.811124
              .
              .
              .
 The string data from the file is then bound to a datatable and displayed it in the datagridview. The datagrid view displays perfectly the data in the correct format.
      
        
 
   When i tried to output the first row and first column value from the datatable associated to it by 
       double columnvalue = Convert.ToDouble(datatble.Rows[0][0]);
 
       this.textview1.text = columnvalue.Tostring();

      The displayed value in the textbox is 256441 instead of 2.56441.  What happens to the decimal column, eventhough i convert the string into a double.

      When i try to make other manipulations as addition or substraction between single cellvalues and display it in a textbox, the manipulations works well except the decimal point. Ex : when i try to add 2.56441 with 4.95127 using 

     double columnvalue = Convert.ToDouble(datatble.Rows[0][0])+Convert.ToDouble(datatble.Rows[1][0]);
 
     the textbox output results with 751568 instead of (7.51568).
    
Could guess that there may be some error in the datatype conversion. I couldnt find where the error lies.

Thanking you all in advance.

Arun

Answers (1)