protected void DeleteButton_Click(object sender, EventArgs e) { DataGridItem item = default(DataGridItem); for (int i = 0; i < grdAdvertise.Items.Count; i++) { item = grdAdvertise.Items[i]; if (item.ItemType == ListItemType.AlternatingItem | item.ItemType == ListItemType.Item) { if (((CheckBox)item.FindControl("ChkSelect")).Checked) { string strId = item.Cells[1].Text; AdvertiseBUS.Advertise_Delete(strId); } } } grdAdvertise.CurrentPageIndex = 0; BindGrid(); }
protected void grdAdvertise_ItemCommand(object source, DataGridCommandEventArgs e) { string strCA = e.CommandArgument.ToString(); switch (e.CommandName) { case "Edit": Id = strCA; List <Data.Advertise> listE = AdvertiseBUS.Advertise_GetById(Id); txtId.Text = strCA; txtName.Text = listE[0].Name; txtsummary.Text = listE[0].Summary; if (listE[0].Image.Length > 0) { txtImage.Text = listE[0].Image; imgImage.Visible = true; imgImage.ImageUrl = listE[0].Image; } if (listE[0].ImageSmall.Length > 0) { txtImagesmall.Text = listE[0].Image; Image1.Visible = true; Image1.ImageUrl = listE[0].ImageSmall; } //else //{ // trImages.Visible = false; //} //txtWidth.Text = listE[0].Width; //txtHeight.Text = listE[0].Height; txtLink.Text = listE[0].Link; ddlTarget.SelectedValue = listE[0].Target; ddlPosition.SelectedValue = listE[0].Position; ddlModule.SelectedValue = listE[0].PageId; txtOrd.Text = listE[0].Ord; 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 [Advertise] set Active=" + strA + " Where Id='" + strCA + "'"); BindGrid(); break; case "Delete": AdvertiseBUS.Advertise_Delete(strCA); BindGrid(); break; case "Image": Response.Redirect("/Admins/ImagesDetail.aspx?ImagesId=" + strCA + ""); break; } }