protected virtual void AddNewRecords() { ArrayList newRecordList = new ArrayList(); System.Collections.Generic.List<Hashtable> newUIDataList = new System.Collections.Generic.List<Hashtable>(); // Loop though all the record controls and if the record control // does not have a unique record id set, then create a record // and add to the list. if (!this.ResetData) { System.Web.UI.WebControls.Repeater rep = (System.Web.UI.WebControls.Repeater)(BaseClasses.Utils.MiscUtils.FindControlRecursively(this, "CategoryTableControlRepeater")); if (rep == null){return;} foreach (System.Web.UI.WebControls.RepeaterItem repItem in rep.Items) { // Loop through all rows in the table, set its DataSource and call DataBind(). CategoryTableControlRow recControl = (CategoryTableControlRow)(repItem.FindControl("CategoryTableControlRow")); if (recControl.Visible && recControl.IsNewRecord) { CategoryRecord rec = new CategoryRecord(); if (recControl.CatDesc.Text != "") { rec.Parse(recControl.CatDesc.Text, CategoryTable.CatDesc); } if (recControl.CatName.Text != "") { rec.Parse(recControl.CatName.Text, CategoryTable.CatName); } if (recControl.ParentCatID.Text != "") { rec.Parse(recControl.ParentCatID.Text, CategoryTable.ParentCatID); } if (recControl.Status.Text != "") { rec.Parse(recControl.Status.Text, CategoryTable.Status); } newUIDataList.Add(recControl.PreservedUIData()); newRecordList.Add(rec); } } } // Add any new record to the list. for (int count = 1; count <= this.AddNewRecord; count++) { newRecordList.Insert(0, new CategoryRecord()); newUIDataList.Insert(0, new Hashtable()); } this.AddNewRecord = 0; // Finally, add any new records to the DataSource. if (newRecordList.Count > 0) { ArrayList finalList = new ArrayList(this.DataSource); finalList.InsertRange(0, newRecordList); Type myrec = typeof(FPCEstimate.Business.CategoryRecord); this.DataSource = (CategoryRecord[])(finalList.ToArray(myrec)); } // Add the existing UI data to this hash table if (newUIDataList.Count > 0) this.UIData.InsertRange(0, newUIDataList); }