ItemDataBound
is only fired when the item is being bound to the data source. That only happens on the initial load; when you click the button to post back to the server, the control tree is recreated without databinding, so the event won't fire.
ItemCreated
would be the event to use to wire up the event handler, if you couldn't do it via the markup for some reason. But it looks like you've already wired it up in the markup, so you shouldn't need to do it again in the code-behind.
I suspect the problem is that you're missing the
event
keyword in the control's code-behind:
public event EventHandler DeductionsUpdated;
event - C# Reference | Microsoft Docs[
^]
You might want to consider using the
Events
property to store the delegate, to mimic how the other events are defined:
private static readonly object DeductionsUpdatedEvent = new object();
public EventHandler DeductionsUpdated
{
add { Events.AddHandler(DeductionsUpdatedEvent, value); }
remove { Events.RemoveHandler(DeductionsUpdatedEvent, value); }
}
protected virtual void OnDeductionsUpdated(EventArgs e)
{
var handler = (EventHandler)Events[DeductionsUpdatedEvent];
handler?.Invoke(this, e);
}
How to: Handle Multiple Events Using Event Properties | Microsoft Docs[
^]