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

Can unformatted grid cell data be accessed?

1 Answer 18 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 09 Oct 2008, 01:33 PM
I have a GridBoundColumn in my grid that holds a decimal that is formatted using this DataFormatString: "{0:#,0.00; (#,0.00);0.00}"

This has the effect of putting brackets around negative numbers, which is what the user has requested, and it works just fine.

At runtime I need to access the unformatted value of this column, i.e. instead of (100,000.00) I need -100000.00. If I use Decimal.Parse() I get a format exception, so I'm wondering if there's a way to access the value that I need via GridDataItem or any other method? I'd really like to avoid having to strip the brackets and add the negative sign manually in code.

Thanks in advance,
Rob

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 09 Oct 2008, 02:01 PM
Hello Rob,

Please test this approach:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    GridDataItem gdi = e.Item as GridDataItem; 
    if (gdi != null
    { 
        Hashtable values = new Hashtable(); 
        gdi.ExtractValues(values); 
        Decimal value = Decimal.Parse(values["yourColumn"].ToString()); 
    } 

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Rob
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or