Setting default field values

This feels like it should be easier to me. I’m trying to set the default qty to 1. I’ve tried changing the value but it doesn’t stay. Have also set the value when the form loads but that doesn’t work either.
What’s the right way to do this?

I’ve banged my head against this before, here’s some code I found to get it to stick (this is on the Corrective Action Entry module) I used the form event wizard to get the EpiViewNotifcation event code, then added the if statement and view.dataView.edit parts:

private void edvDMRCorAct_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
	// ** Argument Properties and Uses **
	// view.dataView[args.Row]["FieldName"]
	// args.Row, args.Column, args.Sender, args.NotifyType
	// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
	if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
	{
		if ((args.Row > -1))
		{
			if (Convert.ToInt32(nonconfTextBox.Value) == 0)
			{
				view.dataView[view.Row].BeginEdit();
				view.dataView[view.Row]["NonConfNum"]=1;
				view.dataView[view.Row].EndEdit();
			}
		}
	}
}

image

After clicking new:

image

You should be able to do something similar and just change the “NonConfNum” part to the desired epibinding.

Thank you @Asz0ka that did the trick. Feel like it should be easier but that isn’t too bad.

1 Like