Gal Ratner
Gal Ratner is a Techie who lives and works in Los Angeles. Follow galratner on Twitter
Error while setting property 'Total': '$0.00 is not a valid value for Decimal.' trying to delete row with EntityDataSource

 While trying to delete a row in a GridView I enccountered a format exception.
I had a bound field that was a decimal formated as money

<asp:BoundField DataField="Total" HeaderText="Total" DataFormatString="{0:C}" SortExpression="Total" />

 The solusion was to define the file’s format in the metadata class as follows:

 

using System.ComponentModel.DataAnnotations;

 

 namespace OfficeLunchOrdersModel

{

    [MetadataType(typeof(LunchOrderItemMetadata))]
     public partial class LunchOrderItem

    {

    }

    public class LunchOrderItemMetadata

    {

        [DisplayFormat(DataFormatString = "{0:C}")]

        public Object Total { get; set; }

    }

}

I then removed DataFormatString="{0:C}" from the BoundField and was able to delete the row.


Posted 11 Jul 2009 6:23 AM by Gal Ratner
Filed under:

Powered by Community Server (Non-Commercial Edition), by Telligent Systems