This is a migrated thread and some comments may be shown as answers.

[Solved] Cell.Value contains applied DataFormatString

1 Answer 112 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Richard Harrigan
Top achievements
Rank 1
Richard Harrigan asked on 16 Dec 2010, 12:54 AM
Hi

I am setting GridViewDataColumn.DataFormatString = {0:c};
For example a cell will render $2.25.  I then change the cell value to 3.55.  (It shows as 3.55 in edit mode)
When exiting the row the RadGridView1_RowValidating event fires (see below).

void RadGridView1_RowValidating(object sender, GridViewRowValidatingEventArgs e)
{
    var oldValues = e.OldValues;
    foreach (KeyValuePair<string, object> kvp in oldValues)
    {
       String key = kvp.Key;        // The value is UnitPrice
       Object value = kvp.Value;    // The value is 2.25   THIS IS GOOD.
    }
      
    GridViewRow myRow = e.Row as GridViewRow;
    foreach (GridViewCell cell in myRow.Cells)
    {
       Object value = cell.Value;  // the value is $3.55  DON"T WANT THE $
     }
}

HOW DO I GET THE REAL VALUE 3.55.   I know i can parse the string and get rid of the $ but this is a generic process, I don't know anything about the data, it is created dynamically using reflection..
       
Thanks
Rich

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 16 Dec 2010, 08:58 AM
Hi Richard Harrigan,

You may try to work directly with the data item and take its value for the corresponding cell, instead of working with the value of the cell. 

Greetings,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
GridView
Asked by
Richard Harrigan
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or