I’m currently trying to validate a part number that a user selects in one of my applications. However, I don’t want the part number to ever get “loaded” into the Part data view; I want to catch it and cancel the adapter method before that happens. Thus, I’m using the oTrans_partAdapter_BeforeAdapterMethod. I found the method name that I want to use it with (“LoadUserResults”)…
However…
I can’t seem to figure out where I can actually “see” the “PartNum” field that’s being tested and loaded through the adapter. Are there any particular properties or methods that I can access here?
In order to do what you are wanting here, you’ll have to reference the EpiDataView contatining your data.
I think it would be a better fit to use BeforeFieldChange on the proper dataview/field:
private void JobMtl_BeforeFieldChange(object sender, DataColumnChangeEventArgs args)
{
// ** Argument Properties and Uses **
// args.Row["FieldName"]
// args.Column, args.ProposedValue, args.Row
// Add Event Handler Code
switch (args.Column.ColumnName)
{
case "PartNum":
if(!CheckPartNum(args.ProposedValue)
{
args.ProposedValue = ""; //or you can set it back to what it was
}
break;
}
}
I made an assumption you have a function CheckPartNum that will say whether your pn is valid or not.