here\'s the deal I got a datagridviewer which is called gridview1 and a fileupload1 when i upload a file it updates the gridview1 and table in database with the file name and pa
In my project i am using ajax and i create a web method in my code behind like this
in front
$("#attachedfiles a").live("click", function () {
var row = $(this).closest("tr");
var fileName = $("td", row).eq(0).html();
$.ajax({
type: "POST",
url: "SendEmail.aspx/RemoveFile",
data: '{fileName: "' + fileName + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function () { },
failure: function (response) {
alert(response.d);
}
});
row.remove();
});
in code behind
[WebMethod]
public static void RemoveFile(string fileName)
{
List files = (List)HttpContext.Current.Session["Files"];
files.RemoveAll(f => f.FileName.ToLower().EndsWith(fileName.ToLower()));
if (System.IO.File.Exists(HttpContext.Current.Server.MapPath("~/Employee/uploads/" + fileName)))
{
System.IO.File.Delete(HttpContext.Current.Server.MapPath("~/Employee/uploads/" + fileName));
}
}
i think this will help you.