0

Hi all,

nothing happen when i download file

Everything looks fine when i debug code.. there is no error

protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        int ID = Convert.ToInt32(e.CommandArgument);
        if (((LinkButton)e.CommandSource).Text == "View")
        {
            Response.Redirect("~/Detail.aspx?id=" + ID );
        }
        else
        {
            GetFile(ID);
        }
    }




public void GetFile(int ID)
        {
            string conStr = "Data Source=localhost;Initial Catalog=My_DB;Integrated Security=True";
            SqlConnection conn = new SqlConnection(conStr);
            conn.Open();
            string query = "Select v From Table where ID=" + ID;
            SqlCommand cmd = new SqlCommand(query, conn);
            Object result = cmd.ExecuteScalar();
            conn.Close();
            if (result != DbNull.Value)
            {
                Response.Clear();
                Response.AddHeader("content-disposition", string.Format("attachment;filename=\"{0}\"", Path.GetFileName(result.ToString())));
                Response.ContentType = "video/mp4";
                Response.TransmitFile(result.ToString());
                Response.End();
            }
        }

I'll be very thankful
Regards

2
Contributors
1
Reply
8
Views
3 Years
Discussion Span
Last Post by yssirhc
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.