Clear grid not working


I have a BAQ grid on Customer, the retrieval button works but when i clear the screen or load up a different customer i want the grid to clear but it does not and not sure where i am going wrong. Below is my code.

// Custom code for CustomerTrackerForm
// Created: 11/10/2017 14:00:32
// **************************************************

extern alias Erp_Contracts_BO_Company;
extern alias Erp_Contracts_BO_ARAgingTracker;

extern alias Erp_Contracts_BO_Customer;
extern alias Erp_Contracts_BO_CreditManager;
extern alias Erp_Contracts_BO_ARInvoice;
extern alias Erp_Contracts_BO_Quote;
extern alias Erp_Contracts_BO_CustCnt;
extern alias Erp_Contracts_BO_ARLOC;
extern alias Erp_Contracts_BO_CashDtlSearch;
extern alias Erp_Contracts_BO_ServiceContract;
extern alias Erp_Contracts_BO_CustShip;
extern alias Erp_Contracts_BO_CashRecSearch;
extern alias Erp_Contracts_BO_ARPromissoryNotes;
extern alias Erp_Contracts_BO_SalesOrdHedDtl;
extern alias Erp_Contracts_BO_OrderDtlSearch;
extern alias Erp_Contracts_BO_ShipDtlSearch;
extern alias Ice_Contracts_BO_DynamicQuery;

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Ice.Lib.Broadcast;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Reflection;
using Ice.BO;

public class Script
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **
	private EpiDataView edvCustomer;
	private int prevCustNum = -1;
	private EpiBaseAdapter oTrans_customerAdapter;
	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **

	public void InitializeCustomCode()
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		this.oTrans_customerAdapter = ((EpiBaseAdapter)(this.csm.TransAdaptersHT["oTrans_customerAdapter"]));
		this.oTrans_customerAdapter.AfterAdapterMethod += new AfterAdapterMethod(this.oTrans_customerAdapter_AfterAdapterMethod);
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls
		edvCustomer = new BAQDataView("InvoiceHedCustTracker");
		oTrans.Add("InvoiceHedCustTrackerBAQ", edvCustomer);
		this.btnRun.Click += new System.EventHandler(this.btnRun_Click);
		// End Wizard Added Custom Method Calls

	public void DestroyCustomCode()
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		edvCustomer = null;

		this.btnRun.Click -= new System.EventHandler(this.btnRun_Click);
		this.oTrans_customerAdapter.AfterAdapterMethod -= new AfterAdapterMethod(this.oTrans_customerAdapter_AfterAdapterMethod);
		this.oTrans_customerAdapter = null;
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal

	private void CustomerTrackerForm_Load(object sender, EventArgs args)
		// Add Event Handler Code
		EpiBasePanel detailPanel1;
		detailPanel1 = (EpiBasePanel)(csm.GetNativeControlReference("8fd5b1fa-db9e-423c-baca-4656696c859b"));

	private void btnRun_Click(object sender, System.EventArgs args)
		// ** Place Event Handling Code Here **


	private void InvoiceHedCustTrackerBAQ()
		EpiUltraGrid vData = (EpiUltraGrid)csm.GetNativeControlReference("35897ae0-bf81-4358-beaa-7b6b41599fa1");

		int iCustNum = 0;
		EpiDataView edvCustomer = ((EpiDataView)(this.oTrans.EpiDataViews["Customer"]));
		System.Data.DataRow edvCustomerRow = edvCustomer.CurrentDataRow;
		if ((edvCustomerRow != null))
			iCustNum = Convert.ToInt32(edvCustomerRow["CustNum"]);
			QueryExecutionDataSet dsExecute = new QueryExecutionDataSet();

			if (iCustNum != 0)
					dsExecute.Tables["ExecutionParameter"].Rows.Add("CustNum", iCustNum, "Integer");
					// Declare and create an instance of the Adapter.
					DynamicQueryAdapter adQuery = new DynamicQueryAdapter(this.oTrans);
					// Declare and Initialize Variables
					string pcQueryID = "InvoiceHedCustTracker"; // replace with your baq
														 // Call Adapter method
					adQuery.ExecuteByID(pcQueryID, dsExecute);
					// table named results has results
					vData.DataSource = adQuery.QueryResults.Tables["Results"]; // vData is a pointer to my Grid
					vData.EpiAutoFit = true; // not sure this works!
					// Cleanup Adapter Reference
				catch (System.Exception ex)

	private void oTrans_customerAdapter_AfterAdapterMethod(object sender, AfterAdapterMethodArgs args)
		// ** Argument Properties and Uses **
		// ** args.MethodName **
		// ** Add Event Handler Code **

		// ** Use MessageBox to find adapter method name
		// EpiMessageBox.Show(args.MethodName)
		switch (args.MethodName)
			case "Clear":
			//prevCustNum = -1;
	private void clearOnDemandGrids()

if (grdOpenInv.DataSource != null)

You probably just need a vData.Datasource=null; when the Customer changes. Maybe in a ListChanged event.