Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hookpresave
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Miscellaneous
Thread ID:
01058130
Message ID:
01058726
Views:
12
Russ,

>How can I replace/change the value of a field (datatable column?) prior to saving the record. I thought the appropriate place may be the HookPreSave, but don't know how to reference the field.
>
>For simplicity I was looking to store the current date/time in a field called update_date

HookPreSave() is a good choice for this. For example, if you want to save the current Date/Time to the "update_date" column in the first row of the DataTable you can do something like this (you can change the DateTime value as needed):
protected override bool HookPreSave(DataTable dt)
{
	dt.Rows[0]["update_date"] = DateTime.Now;
	return true;
}
Or if you want to save the Date/Time value to the "current" DataRow in the business object you can do something like this:
protected override bool HookPreSave(DataTable dt)
{
	this.DataRow["update_date"] = DateTime.Now;
	return true;
}
FYI, in the second example, you need to make sure in your particular case that the DataRow property contains the DataRow you are interested in.

Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Reply
Map
View

Click here to load this message in the networking platform