以下是我的代码段:
protected void grdDownload_Command(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Download")
{
int index = Convert.ToInt32(e.CommandArgument);
DataTable dtFilterData = `enter code here`GetPDFFile("D", Convert.ToString(index));
Response.Clear();
Response.Buffer = true;
Response.ContentType = dtFilterData.Rows[0]["ContentType"].ToString();
Response.AddHeader("content-disposition", "attachment;filename=" + dtFilterData.Rows[0]["Name_File"].ToString()); // to open file prompt Box open or Save file
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.BinaryWrite((byte[])dtFilterData.Rows[0]["FileData"]);
Response.End();
}
}
答案 0 :(得分:0)