I am using List<>
in C# . I want to add values in the List
. But problem is that first item add successfully but when second item insert the same value ovverride into the first one , example first item abc
inserted succefully but when second item xyz
came it ovveride abc
to xyz
and both items shows xyz
.Here is my code.
DataTable dtbl3 = new DataTable();
List<CartItems> lst = (List<CartItems>)Session["mycart"];
dtbl3 = DAL.Get("Select * from mytable");
List<EmailClass> lstCstmer = new List<EmailClass>();
for (int j = 0; j < lst.Count; j++)
{
emailLst.__EmailcstName = dtbl3.Rows[0]["cstm_name"].ToString();
emailLst.__EmailcstLName = dtbl3.Rows[0]["cstm_LName"].ToString();
emailLst.__EmailcstAddress = dtbl3.Rows[0]["cstm_Addr"].ToString();
emailLst.__EmailcstPhoneNo = dtbl3.Rows[0]["cstm_Phone"].ToString();
emailLst.__EmailcstCellNo = dtbl3.Rows[0]["cstm_CellNo"].ToString();
emailLst.__EmailcstskypId = dtbl3.Rows[0]["cstm_skypeId"].ToString();
emailLst.__EmailcstEmail = dtbl3.Rows[0]["cstm_email"].ToString();
emailLst.__EmailcstCountry = dtbl3.Rows[0]["cstm_country"].ToString();
emailLst.__EmailcstCity = dtbl3.Rows[0]["cstm_City"].ToString();
emailLst.__EmailcstZipcode =Convert.ToInt32( dtbl3.Rows[0]["cstm_ZipCode"].ToString());
emailLst.__EmailcstRemarks = dtbl3.Rows[0]["cstm_remarks"].ToString();
emailLst._EmailCartProdName = lst[j]._CartProdName;
emailLst._EmailCartProdPrice = lst[j]._CartProdPrice;
emailLst._EmailCartProdQnty = lst[j]._CartProdQnty;
emailLst._EmailCartProdCode = lst[j]._CartProdName;
emailLst._EmailTotalProdPrice = lst[j]._TotalProdPrice;
lstCstmer.Add(emailLst);
}