protected void grdAdvertise_ItemCommand(object source, DataGridCommandEventArgs e) { string strCA = e.CommandArgument.ToString(); switch (e.CommandName) { case "Edit": Insert = false; Id = strCA; dt = AdvertiseService.Advertise_GetById(Id); //LoadDropDownListPage(); txtName.Text = dt.Rows[0]["Name"].ToString(); txtImage.Text = dt.Rows[0]["Image"].ToString(); imgImage.ImageUrl = dt.Rows[0]["Image"].ToString().Length > 0 ? dt.Rows[0]["Image"].ToString() : ""; txtWidth.Text = dt.Rows[0]["Width"].ToString(); txtHeight.Text = dt.Rows[0]["Height"].ToString(); txtLink.Text = dt.Rows[0]["Link"].ToString(); PageHelper.LoadDropDownListTarget(ddlTarget); ddlTarget.SelectedValue = dt.Rows[0]["Target"].ToString(); PageHelper.LoadDropDownListPosition(ddlPosition); PageHelper.LoadDropDownListLanguage(ddlLanguage); ddlPosition.SelectedValue = dt.Rows[0]["Position"].ToString(); ddlLanguage.SelectedValue = dt.Rows[0]["Language"].ToString(); txtOrd.Text = dt.Rows[0]["Ord"].ToString(); chkActive.Checked = dt.Rows[0]["Active"].ToString() == "1" || dt.Rows[0]["Active"].ToString() == "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": AdvertiseService.Advertise_Delete(strCA); BindGrid(); break; } }
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; AdvertiseService.Advertise_Delete(strId); } } } grdAdvertise.CurrentPageIndex = 0; BindGrid(); }