I am working on a page that displays the pdf files in a specific directory in a grid, along with a link to the file.
I am modifying Scott Mitchell's example here: https://web.archive.org/web/20210518230005/http://aspnet.4guysfromrolla.com/articles/052803-1.aspx
I converted the code from vb to c#.
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server">
public void Page_Load(object sender, EventArgs e)
{
DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath(""));
articleList.DataSource = dirInfo.GetFiles("*.pdf");
articleList.DataBind();
}
</script>
<asp:DataGrid runat="server" id="articleList" Font-Name="Verdana"
AutoGenerateColumns="False" AlternatingItemStyle-BackColor="#eeeeee"
HeaderStyle-BackColor="Navy" HeaderStyle-ForeColor="White"
HeaderStyle-Font-Size="15pt" HeaderStyle-Font-Bold="True">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name"
HeaderText="File Name" target="_blank"/>
<asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time"
ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" />
</Columns>
</asp:DataGrid>
The above code works in displaying the files. What I would like to do now is add grid filtering.
The file name is displayed in the grid as a link to the pdf. How can I add a text field that lets you filter/search for a specific file name, or a file name that begins with __?
Also, would it be possible to keep the browser from caching the pdf, since all my page does is provide a link to it?
Any help or ideas would be appreciated.
Thanks.