private bool Delete() { bool boRetValue = false; string stIDs = ""; foreach (DataListItem item in lstAccountSummary.Items) { DataList lstAccountCategory = (DataList)item.FindControl("lstAccountCategory"); foreach (DataListItem itemAccountCategory in lstAccountCategory.Items) { DataList lstChartOfAccounts = (DataList)itemAccountCategory.FindControl("lstChartOfAccounts"); foreach (DataListItem itemChartOfAccounts in lstChartOfAccounts.Items) { HtmlInputCheckBox chkList = (HtmlInputCheckBox)itemChartOfAccounts.FindControl("chkList"); if (chkList != null) { if (chkList.Checked == true) { stIDs += chkList.Value + ","; boRetValue = true; } } } } } if (boRetValue) { ChartOfAccounts clsChartOfAccount = new ChartOfAccounts(); clsChartOfAccount.Delete(stIDs.Substring(0, stIDs.Length - 1)); clsChartOfAccount.CommitAndDispose(); } return(boRetValue); }