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