我有這樣的代碼列表<Entity>問題
foreach(GridViewRow row in gvTagDeductionList.Rows)
{
DeductionEntity de = new DeductionEntity();
//modify this condition, make cell number to be more dynamic
if (((CheckBox)row.Cells[2].FindControl("chkInclude")).Checked == true)
{
//following id's are said to be in numeric format in the first place
//ede.EmployeeID = Convert.ToInt32(HttpContext.Current.Session["_newEmpID"].ToString());
ede.DeductionID = Convert.ToInt32((((Label)row.Cells[0].FindControl("lblID")).Text).ToString());
ede.CreatedBy_UserID = Convert.ToInt32(HttpContext.Current.Session["_employeeID"].ToString());
ede.UpdatedBy_UserID = Convert.ToInt32(HttpContext.Current.Session["_employeeID"].ToString());
de = e201u.GetDeductionDetails(ede.DeductionID);
e201u.InsertEmployeeDeduction(ede);
lstEntity.Add(de);
}
}
de = e201u.GetDeductionDetails(ede.DeductionID);
內環路這段代碼的第二次相遇後,在這段代碼lstEntity.Add(de);
第一個記錄將被改變,最後我會在最後兩在我的最後一個實體列表中獲得條目de = e201u.GetDeductionDetails(ede.DeductionID);
如果您正在將所有內容分配給'e201u.GetDeductionDetails' – Marlon 2011-03-02 06:46:06
您不需要創建一個新的DeductionEntity應該使用事件,而不是每次發生事件時遍歷整個數據網格。只是我2美分。 – leppie 2011-03-02 07:20:37