Moved the add tab logic to the grid onchange event.