You're formatting the column to show the $ sign. But that makes it invalid for DB operations. One way to resolve, I think, is to handle the rowdeleting event, and remove the $ sign from that value. You can get access to it from the "e" parameter of the
handler.
That's bull because it shouldn't even be passing back the Amount field. I just want to delete a row so all it should care about is the Primary Key field, right?!
I grudgingly went the route of removing the formatting from the value in a GridView RowDeleting event handler. What is this metadata class you speak of? an EntityFramework thing? an EntityDataSource thing? or a GridView thing?
Member
20 Points
312 Posts
Error when deleting in Gridview and EntityDataSource when column has DataFormatString
Jan 18, 2009 04:49 PM|javan15|LINK
I keep on getting an error when trying to delete a record in a gridview that is bound to an entitydatasource. The error I get is:
Error while setting property 'Amount': '$120.00 is not a valid value for Decimal.'.
Can someone please help? Below is my markup
Use the form to the right to create a personal expense
</h1> </EmptyDataTemplate> </asp:GridView> <asp:EntityDataSource ID="dsEmployeePersonalExpenses" runat="server" Include="TransactionCategory" EnableDelete="True" ContextTypeName="MYCONTEXTTYPENAMEHE" OrderBy="it.ExpenseDate desc" EntitySetName="EmployeePersonalExpenseSet" Where="it.Employee.EmployeeId = @employeeId"> <WhereParameters> <asp:Parameter Name="employeeId" Type="Int32" /> </WhereParameters> </asp:EntityDataSource>All-Star
101931 Points
20703 Posts
Re: Error when deleting in Gridview and EntityDataSource when column has DataFormatString
Jan 18, 2009 09:20 PM|MetalAsp.Net|LINK
You're formatting the column to show the $ sign. But that makes it invalid for DB operations. One way to resolve, I think, is to handle the rowdeleting event, and remove the $ sign from that value. You can get access to it from the "e" parameter of the handler.
Member
20 Points
312 Posts
Re: Error when deleting in Gridview and EntityDataSource when column has DataFormatString
Jan 18, 2009 10:34 PM|javan15|LINK
That's bull because it shouldn't even be passing back the Amount field. I just want to delete a row so all it should care about is the Primary Key field, right?!
All-Star
17916 Points
5681 Posts
MVP
Re: Error when deleting in Gridview and EntityDataSource when column has DataFormatString
Jan 19, 2009 03:30 AM|sjnaughton|LINK
Have you tried putting the formatting into the metadata class as I've had no problems deleteing row that have the format applied that way.
Dynamic Data DataFormat
Always seeking an elegant solution.
None
0 Points
2 Posts
Re: Error when deleting in Gridview and EntityDataSource when column has DataFormatString
Jun 05, 2009 12:28 PM|nc1943|LINK
I grudgingly went the route of removing the formatting from the value in a GridView RowDeleting event handler. What is this metadata class you speak of? an EntityFramework thing? an EntityDataSource thing? or a GridView thing?
All-Star
17916 Points
5681 Posts
MVP
Re: Error when deleting in Gridview and EntityDataSource when column has DataFormatString
Jun 05, 2009 12:41 PM|sjnaughton|LINK
this thread relates to Dynamic Data for ASP.Net and not generic ASP.Net see ASP.NET Dynamic Data for more on Dynamic Data
Dynamic Data
Always seeking an elegant solution.
None
0 Points
5 Posts
Re: Error when deleting in Gridview and EntityDataSource when column has DataFormatString
Jan 06, 2011 07:08 AM|rpelepei|LINK
I have solve the problem by setting DataFormatString="{0:N}