【发布时间】:2011-04-11 10:53:23
【问题描述】:
<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 标记,下面是数据绑定部分
DirectoryInfo ProviderFolder = new DirectoryInfo(strFolderPath);
FileInfo[] BrochureList = ProviderFolder.GetFiles();
if (BrochureList.Length > 0)
{
GrdVw_Download.DataSource = BrochureList;
GrdVw_Download.DataBind();
}
在这一行的网格视图中<a href="?dl=<%# Encyptor.encrypt(((FileInfo)Container.DataItem).FullName) 我得到了帖子谈到的错误。 Encryptor 在哪里加密 FilePath 和标记生成一个链接来下载文件
编辑抱歉:
*解决了。* 这不是文件名,只是名称。再次抱歉
【问题讨论】:
-
您应该接受真正解决了您的问题的答案,而不是在问题标题中添加“[已解决]”。
-
@Martin 感谢您提供的信息。我会接受一个答案是他在我更新之前发布了解决方案。当我用我犯的错误更新问题时。
标签: asp.net data-binding gridview directory fileinfo