protected void Button3_Click(object sender, EventArgs e) { Button bn = sender as Button; GridViewRow gr = bn.NamingContainer as GridViewRow; string path = GridView1.DataKeys[gr.RowIndex].Value.ToString(); Response.ContentType = "image/jpg"; Response.AddHeader("Content-Disposition", "attachment;filename=\"" + path + "\""); Response.TransmitFile(Server.MapPath(path)); // The error is here Response.End(); }
protected void Button1_Click(object sender, EventArgs e) { string filename2 = Path.GetFileName(FileUpload1.PostedFile.FileName); FileUpload1.SaveAs(Server.MapPath("Files/" + filename2)); SqlCommand com = new SqlCommand("insert into song (sname,path) values (@s,@p)", c1.cn); com.Parameters.AddWithValue("@s", SqlDbType.NVarChar).Value = TextBox1.Text; com.Parameters.AddWithValue("@p", SqlDbType.NVarChar).Value = "Files/" + filename2; c1.cn.Open(); com.ExecuteNonQuery(); c1.cn.Close(); }
<httpRuntime maxRequestLength="2097151" executionTimeout="9999"/> </system.web>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)