首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

repeater控件下的LinkButton实现下载工呢过,该如何处理

2012-03-19 
repeater控件下的LinkButton实现下载工呢过用OnCommand事件怎么没反应,错也不报C# codeprotected void Dow

repeater控件下的LinkButton实现下载工呢过
用 OnCommand事件怎么没反应,错也不报  
 

C# code
  protected void DownLoadBtn_Command(object sender,CommandEventArgs  e)    {        if (e.CommandName == "DownLoad")        {            DataSet ds = bll_FileMan.CheckIsFile(RootID);            if (ds != null && ds.Tables[0].Rows.Count > 0)            {                string path = Session["FolderPath"] + ds.Tables[0].Rows[0]["FileName"].ToString();                FileInfo fi = new FileInfo(path);                if (fi.Exists)                {                    Response.AddHeader("content-type", "application/x-msdownload");                    Response.AddHeader("Content-Disposition", "attachment;filename="                    + System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(fi.Name)));                    Response.Flush();                }                FileStream streamFile = File.OpenRead((Session["FolderPath"] + "/" + ds.Tables[0].Rows[0]["FileName"].ToString()));                byte[] byteFile = new byte[streamFile.Length];                streamFile.Read(byteFile, 0, int.Parse(streamFile.Length.ToString()));                Response.BinaryWrite(byteFile);                Response.End();            }        }    }


[解决办法]
C# code
protected void DownLoadBtn_Command(object sender,CommandEventArgs  e)    {        if (e.CommandName.Equals("DownLoad"))        {            DataSet ds = bll_FileMan.CheckIsFile(RootID);            if (ds != null && ds.Tables[0].Rows.Count > 0)            {                string path = Session["FolderPath"] + ds.Tables[0].Rows[0]["FileName"].ToString();                FileInfo fi = new FileInfo(path);                if (fi.Exists)                {                    Response.AddHeader("content-type", "application/x-msdownload");                    Response.AddHeader("Content-Disposition", "attachment;filename="                    + System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(fi.Name)));                    Response.Flush();                }                FileStream streamFile = File.OpenRead((Session["FolderPath"] + "/" + ds.Tables[0].Rows[0]["FileName"].ToString()));                byte[] byteFile = new byte[streamFile.Length];                streamFile.Read(byteFile, 0, int.Parse(streamFile.Length.ToString()));                Response.BinaryWrite(byteFile);                Response.End();            }        }    }
[解决办法]
字符串比较 不要用"=="来做
[解决办法]
字符串比较 不要用"=="来做

热点排行