protected void grdBooking_ItemCommand(object source, DataGridCommandEventArgs e) { try { string strCa = e.CommandArgument.ToString(); txtId.Text = e.CommandArgument.ToString(); if (e.CommandName == "Edit") { grdCustomer.DataSource = BookingService.Booking_GetById(strCa); grdCustomer.DataBind(); grdShopcard.DataSource = BookingService.Booking_GetById(strCa); grdShopcard.DataBind(); pnUpdate.Visible = true; pnView.Visible = false; } if (e.CommandName == "Delete") { BookingService.Booking_Delete(strCa); BindGrid(); } } catch (Exception ex) { WebMsgBox.Show(ex.Message); } }
protected void lbtDeleteB_Click(object sender, EventArgs e) { try { DataGridItem item = default(DataGridItem); for (int i = 0; i < grdBooking.Items.Count; i++) { item = grdBooking.Items[i]; if (item.ItemType == ListItemType.AlternatingItem | item.ItemType == ListItemType.Item) { if (((CheckBox)item.FindControl("ChkSelect")).Checked) { string strId = item.Cells[1].Text; var dt = new DataTable(); BookingService.Booking_Delete(strId); } } } grdBooking.CurrentPageIndex = 0; BindGrid(); } catch (Exception ex) { WebMsgBox.Show(ex.Message); } }