Setting default field values

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.