protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=MinisanteDb;Integrated Security=True"); SqlCommand com = new SqlCommand("select name,type,data from uploadd where name=@name", con); com.Parameters.AddWithValue("name", GridView1.SelectedRow.Cells[1].Text); con.Open(); //con.Close(); SqlDataReader dr = com.ExecuteReader(); if (dr.Read()) { Response.Clear(); Response.Buffer = true; Response.ContentType = dr["type"].ToString(); Response.AddHeader("content-disposition", "attachment;filename=" + dr["name"].ToString()); // to open file prompt Box open or Save file Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite((byte[])dr["data"]); Response.End(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)