protected void grdGroupImages_ItemCommand(object source, DataGridCommandEventArgs e) { string strCA = e.CommandArgument.ToString(); switch (e.CommandName) { case "AddSub": Level = strCA; AddButton_Click(source, e); break; case "Edit": Insert = false; Id = strCA; List <Data.GroupImages> listE = GroupImagesService.GroupImages_GetById(Id); Level = listE[0].Level.Substring(0, listE[0].Level.Length - 5); txtName.Text = listE[0].Name; txtOrd.Text = listE[0].Ord; PageHelper.LoadDropDownListLanguage(ddlLanguage); ddlLanguage.SelectedValue = listE[0].Language; chkActive.Checked = listE[0].Active == "1" || listE[0].Active == "True"; pnView.Visible = false; pnUpdate.Visible = true; break; case "Active": string strA = ""; string str = e.Item.Cells[2].Text; strA = str == "1" ? "0" : "1"; SqlDataProvider sql = new SqlDataProvider(); sql.ExecuteNonQuery("Update [GroupImages] set Active=" + strA + " Where Id='" + strCA + "'"); BindGrid(); break; case "Delete": GroupImagesService.GroupImages_Delete(strCA); SqlDataProvider sql1 = new SqlDataProvider(); sql1.ExecuteNonQuery("Delete From [Images] where GroupId='" + strCA + "'"); BindGrid(); break; } }
protected void DeleteButton_Click(object sender, EventArgs e) { DataGridItem item = default(DataGridItem); for (int i = 0; i < grdGroupImages.Items.Count; i++) { item = grdGroupImages.Items[i]; if (item.ItemType == ListItemType.AlternatingItem | item.ItemType == ListItemType.Item) { if (((CheckBox)item.FindControl("ChkSelect")).Checked) { string strId = item.Cells[1].Text; GroupImagesService.GroupImages_Delete(strId); SqlDataProvider sql = new SqlDataProvider(); sql.ExecuteNonQuery("Delete From [Images] where GroupId='" + strId + "'"); } } } grdGroupImages.CurrentPageIndex = 0; BindGrid(); }