protected void Grid_RowCommand(object sender, GridCommandEventArgs e) { int artId = GetSelectedDataKeyID(Grid); if (e.CommandName == "Delete") { Maticsoft.BLL.tArticle BLL = new Maticsoft.BLL.tArticle(); Maticsoft.Model.tArticle model = BLL.GetModel(artId); if (!string.IsNullOrEmpty(model.FengMian) && (model.FengMian != "../../upload/blank.png")) { string directoryPath = Server.MapPath(model.FengMian); File.Delete(directoryPath); //删除掉原来的图片 } BLL.Delete(artId); GetView(); } if (e.CommandName == "Edit") { PageContext.RegisterStartupScript(Window1.GetShowReference("ArticlesEdit.aspx?Id=" + artId)); } }