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