0
我需要通過循環兩組數據來創建自定義列表。下面是我正在使用的,但是當我將它附加到我的列表視圖時,我只獲取最後一條記錄。我試着移動this.CoeListitem =新列表,我知道是第一個循環上方的問題,但沒有返回任何記錄。那麼,如何設置這個來創建具有正確記錄數量的List。 這裏是我的如何創建一個自定義列表,包含循環中的幾列
public class CoeList
[PrimaryKey, AutoIncrement]
public long Id { get; set; }
public string Name { get; set; }
public string CreateDt { get; set; }
這裏是我的循環,首先是讓我科項目,二是讓所有去各個科項目成年人可能是許多這就是爲什麼我需要兩個循環。
//new loop
List<Coe> allCoe = (List<Coe>)((OmsisMobileApplication)Application).OmsisRepository.GetAllCoe();
if (allCoe.Count > 0)
{
foreach (var Coeitem in allCoe)
{
//take the coe id and get the adults
List<Adult> AdultsList = (List<Adult>)((OmsisMobileApplication)Application).OmsisRepository.GetAdultByCoeMID(Coeitem.Id);
if (AdultsList.Count > 0)
{
foreach (var AdltItem in AdultsList)
{
CoeNames += "; " + AdltItem.LName + ", " + AdltItem.FName;
}
}
CoeNames = CoeNames.Substring(1);
//ceate new list for coelist
this.CoeListitem = new List<CoeList>()
{
new CoeList() { Id = Coeitem.Id, CreateDt = Coeitem.CreateDt, Name = CoeNames }
};
}
}
// End loop
_list.Adapter = new CoeListAdapter(this, CoeListitem);