I have a pretty odd problem. I was working on an item editing page end encountered some odd bug, that ASP passess old values to C# .cs
code.
In my Page_Load
private int SomeID = 0;
if (!IsPostBack) {
...
SomeID = Convert.ToInt32(Page.RouteData.Values["id"])
LoadFunction();
}
Loading function:
DataBaseDataContext db = new DataBaseDataContext();
var Item = db.FirstOrDefault(k => k.ID == SomeID);
NameTextBox.Text = Item.Name;
PriceTextBox.Text = Item.Price.ToString();
Saving function:
DataBaseDataContext db = new DataBaseDataContext();
var Item = db.FirstOrDefault(k => k.ID == SomeID);
Item.Name = NameTextBox.Text;
Item.Price = Convert.ToDecimal(PriceTextBox.Text);
...
db.SubmitChanges();
I was bothering, why it doesn't save changes for me, so I set breakpoint in db.SubmitChanges()
in the saving function (loading works fine). But when I looked up in value preview in VisualStudio, it showed me that it wants to send previously loaded values and not those I edited in my form.
I must be missing something, as it works in other places of my code, but I have no idea what it is.