Add row to EpiDataView

I’m refactoring some code that I posted yesterday for the HH Cycle Count Entry screen. I have all of the searches etc working using BO, but struggling with populating 2 values into the “tagView” EDV that exists on the form.

adapterCCTag.BOConnect();

bool morePages;
SearchOptions opts = new SearchOptions(SearchMode.AutoSearch);
opts.DataSetMode = DataSetMode.RowsDataSet;
string whereClause = "TagStatus = 0 AND TagReturned = 0 BY BinNum, PartNum";
opts.NamedSearch.WhereClauses.Add("CCTag", whereClause);
opts.PageSize = 1;
   	        	     			
DataSet dsCCTagSearch = adapterCCTag.GetRows(opts, out morePages);
			
if (dsCCTagSearch.Tables["CCTag"].Rows.Count > 0)
{
	EpiDataView edvTag = ((EpiDataView)(oTrans.EpiDataViews["tagView"]));
	System.Data.DataRow edvTagRow = edvTag.CurrentDataRow;
		
	if ((edvTagRow != null))
	{			
		MessageBox.Show("WH contains: " + edvTagRow["WarehouseCode"]);
	
		edvTagRow.BeginEdit();
		edvTagRow["WarehouseCode"] = dsCCTagSearch.Tables["CCTag"].Rows[0]["WarehouseCode"];
		edvTagRow["TagNum"] = dsCCTagSearch.Tables["CCTag"].Rows[0]["TagNum"];
		edvTagRow.EndEdit();
	}

}

I’m finding that there is no edvTagRow, hence not reaching that if statement. On the screen itself, when you provide Warehouse Code, then TagNum and leave the field it creates a Row (confirmed using row counts).

How best to create a row myself in code?

below code you can use


                var dataRow = this.edvPrevPerf.dataView.Table.NewRow();
                dataRow["Tran ID"] = 123;
                dataRow["TranQty"] = 10;
                this.edvPrevPerf.dataView.Table.Rows.Add(dataRow);
``

@josecgomez - you posted this on another post that I found. This seems a good way to achieve what I want - I used ILSpy to check the base form, and when leaving the TagNum field it does call GetByID.

How do I find out the name of the adapter to use - I’m on the HH Count Entry form.

Get a hold of the existing adapter instead of instantiating your own like this (warning winging it without an editor so syntax may not be perfect)

var myInspAdapter = ((InspProcessingAdapter)(this.csm.TransAdaptersHT["oTrans_inspAdapter"]));
myInspAdapter.GetReceiptByID(....) etc...
oTrans.NotifyAll();

I found there is a property? called EpiTransaction.AdapterList, but it won’t let me use a foreach on that to iterate and find the adapter name.

I will also give your suggestion a try and provide feedback - thanks Surendra

I ended up just setting the textboxes, then moving focus and that’s been working well ever since. The edv wasn’t playing nice.