string filename = Path.GetFileName(fileUpload1.PostedFile.FileName); fileUpload1.SaveAs(Server.MapPath("Files/"+filename)); conn.Open(); SqlCommand cmd = new SqlCommand("insert into upload(FileName,FilePath) values(@Name,@Path)",conn); cmd.Parameters.AddWithValue("@Name",filename ); cmd.Parameters.AddWithValue("@Path", "Files/"+filename ); cmd.ExecuteNonQuery(); conn.Close(); BindGridviewData(); </pre>
LinkButton lnkbtn = sender as LinkButton; GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow; string filePath = gvDetails.DataKeys[gvrow.RowIndex].Value.ToString(); Response.ContentType = ""; Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filePath + "\""); Response.TransmitFile(Server.MapPath(filePath)); Response.End(); </pre>
Response.ContentType = "application/octet-stream";
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)