Change update value of property (LINQTOSQL)
Posted
by Dynde
on Stack Overflow
See other posts from Stack Overflow
or by Dynde
Published on 2010-03-17T09:57:50Z
Indexed on
2010/03/17
10:01 UTC
Read the original article
Hit count: 197
Hi...
I've got an entity object - Customer, with a property called VATRate. This VATRate is in the form of a decimal (0.25). I wanted to be able to enter a percentage value, and save it in the correct decimal value in the database, so I made this custom property:
partial class Customer{
public decimal VatPercent {
get{ ... //Get code works fine}
set {
this.VATRate = (value / 100);
}
}
}
And then I just bind this property instead of VATRate in my ASPX editTemplate (formview).
This actually works - at least one time, when I debug an update, the value is set correctly one time, and then right after it gets set to the old value. I can't really see why it sets the value twice (and with the old value the second time). Can anyone shed some light on this?
© Stack Overflow or respective owner