protected void rptNewsCategory_ItemCommand(object source, RepeaterCommandEventArgs e) { int iD = int.Parse(e.CommandArgument.ToString()); switch (e.CommandName.ToString()) { case "update": News_Catagories ca = new News_Catagories(); ca = daNewCategory.Select(n => n.CateID == iD).FirstOrDefault(); txtCatagory.Text = ca.vName.ToString(); txtOrder.Text = ca.vOrder.ToString(); hdID.Value = e.CommandArgument.ToString(); hdInsert.Value = e.CommandName.ToString(); mulView.ActiveViewIndex = 1; txtSave.Text = "update"; break; case "delete": News_Catagories ca1 = new News_Catagories(); ca = daNewCategory.Select(n => n.CateID == iD).FirstOrDefault(); daNewCategory.Delete(ca); Response.Redirect(Request.Url.ToString()); break; } }
protected void rptTinTuc_ItemCommand(object source, RepeaterCommandEventArgs e) { int iD = int.Parse(e.CommandArgument.ToString()); hdID.Value = e.CommandArgument.ToString(); hdOption.Value = e.CommandName.ToString(); News_Detail detail = daNewsDetail.Select(n => n.DelID == iD).FirstOrDefault(); switch (e.CommandName.ToString()) { case "update": mul.ActiveViewIndex = 1; btnUpload.Text = "Dang Cap Nhat"; txtAuthor.Text = detail.vAuthor; txtDes.Text = detail.vDesc; txtTitle.Text = detail.vTitel; FreeTextBox1.Text = detail.vContent; hdImage.Value = detail.vImage; drpNewcatagory.SelectedValue = detail.CateID.ToString(); ckActive.Checked = Convert.ToBoolean(detail.Active); break; case "delete": daNewsDetail.Delete(detail); System.IO.File.Delete(Server.MapPath("/img/") + detail.vImage); Response.Redirect(Request.Url.ToString()); break; default: break; } }