2011-04-11 73 views
0
<asp:GridView runat="server" id="GrdVw_Download"> 
         <RowStyle cssclass="ItemStyle" /> 
         <HeaderStyle cssclass="tableheader" horizontalalign="Left" /> 
         <AlternatingRowStyle cssclass="AlternateItemStyle" horizontalalign="Left" /> 
         <FooterStyle backcolor="#5D7B9D" font-bold="True" forecolor="White" /> 
         <Columns> 
          <asp:BoundField headertext="File name" headerstyle-horizontalalign="Center" itemstyle-horizontalalign="Center" 
           datafield="FileName" /> 
          <asp:BoundField headertext="File Size" headerstyle-horizontalalign="Center" itemstyle-horizontalalign="Center" 
           dataformatstring="{0:#,### bytes}" datafield="Length" /> 
          <asp:BoundField headertext="Extension" headerstyle-horizontalalign="Center" itemstyle-horizontalalign="Center" 
           datafield="Extension" /> 
          <asp:TemplateField headertext="Download Brochure" itemstyle-horizontalalign="Center" 
           headerstyle-horizontalalign="Center"> 
           <ItemTemplate> 
            <a href="?dl=<%# Encryptor.encrypt(((FileInfo)Container.DataItem).FullName) %>" 
            title="Download <%# ((FileInfo)Container.DataItem).FileName %>"> 
             <%# ((FileInfo)Container.DataItem).FileName %> 
            </a> 
           </ItemTemplate> 
          </asp:TemplateField> 
         </Columns> 
        </asp:GridView> 

这是我的GridView标记和下面是绑定部分“System.IO.FileInfo”不包含定义“文件名”

DirectoryInfo ProviderFolder = new DirectoryInfo(strFolderPath); 
    FileInfo[] BrochureList = ProviderFolder.GetFiles(); 
    if (BrochureList.Length > 0) 
    { 
     GrdVw_Download.DataSource = BrochureList; 
     GrdVw_Download.DataBind(); 
    } 

在GridView在此行<a href="?dl=<%# Encyptor.encrypt(((FileInfo)Container.DataItem).FullName)我得到的错误该职位谈到。 Where Encryptor加密FilePath和标记生成链接以下载文件 编辑对不起: * 解决了它。 *它不是文件名,但只是Name.Sorry再次

+0

与问题标题中添加“[Solved]”相反,您应该接受实际解决问题的答案。 – 2011-04-11 11:03:46

+0

@Martin感谢您的信息。我会接受一个答案是他在更新之前发布了解决方案。虽然我正在更新我犯的错误问题。 – Deeptechtons 2011-04-11 11:22:18

回答

1

这是因为“System.IO.FileInfo”不包含定义“文件名”

您是否在寻找FullNameName吧?

+0

您在更新时必须发布此信息。我更新了我原来的帖子 – Deeptechtons 2011-04-11 10:57:13