private bool Delete() { bool boRetValue = false; string stIDs = ""; foreach (DataListItem item in lstStuff.Items) { HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList"); if (chkList != null) { if (chkList.Checked == true) { stIDs += chkList.Value + ","; boRetValue = true; } } } if (boRetValue) { PromoItems clsPromoItems = new PromoItems(); clsPromoItems.Delete(stIDs.Substring(0, stIDs.Length - 1)); clsPromoItems.CommitAndDispose(); } return(boRetValue); }
protected void lstStuff_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e) { HtmlInputCheckBox chkList = (HtmlInputCheckBox)e.Item.FindControl("chkList"); switch (e.CommandName) { case "imgItemDelete": { PromoItems clsPromoItems = new PromoItems(); clsPromoItems.Delete(chkList.Value); clsPromoItems.CommitAndDispose(); LoadList(); } break; } }