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) { PromoBySupplierItems clsPromoBySupplierItems = new PromoBySupplierItems(); clsPromoBySupplierItems.Delete(stIDs.Substring(0,stIDs.Length-1)); clsPromoBySupplierItems.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": { PromoBySupplierItems clsPromoBySupplierItems = new PromoBySupplierItems(); clsPromoBySupplierItems.Delete(chkList.Value); clsPromoBySupplierItems.CommitAndDispose(); LoadList(); } break; } }