public void filedownload() { con.Open(); string command="select * from tblname where int_filename="+FileUpload.FileName+""; string path = Server.MapPath("images\\" + command); FileInfo file = new FileInfo(path); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); Response.AddHeader("Content-Length", file.Length.ToString()); Response.ContentType = "application/octet-stream"; Response.WriteFile(file.FullName); con.Close(); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string p = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "FileName")); } } protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = GridView1.SelectedRow; } protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); LinkButton lblProdId = (LinkButton)row.FindControl("FileName"); string s=lblProdId.Text; if (e.CommandName == "filedownload") { filedownload(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)