Naresh Babu Gopavaram

Naresh Babu Gopavaram

  • 1.5k
  • 248
  • 249k

Only last record is added in the List

Jul 25 2011 6:07 AM
 List<LocationInfornationLocation> locatonsList = new List<LocationInfornationLocation>();
            foreach (var item in businessEntityList)
            {
                lcoationInfo.LocationName = item.LocationDetails.LocationName.ToString() + "_" + item.LocationDetails.LocationId;
                lcoationInfo.BusinessEntityId =Convert.ToUInt16(item.ID);
                locatonsList.Add(lcoationInfo);
            }
            return locatonsList;

Hi I am getting 3 records from the database but when I do the above looping only 3rd record is displayed in place of 3 records .Can any one solve this please. 

Answers (2)