Note that there are some explanatory texts on larger screens.

plurals
  1. POOpen PDF in default viewer from DataGrid
    primarykey
    data
    text
    <p>I have a grid that displays a name &amp; link to all of the pdf files in a folder. The link opens the file in the browser.</p> <p>This is not ideal because the browser caches the files, so if a document is moved or changed, the old cached version is still accessible.</p> <p>Would it be possible to have the link open the file in the default installed pdf viewer and avoid caching completely?</p> <p>Here is my Grid code:</p> <pre><code>&lt;form runat="server"&gt; Search for a file: &lt;asp:TextBox ID="txtFilter" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;asp:Button ID="btnShow" runat="server" Text="Display" onclick="btnShow_Click" /&gt; &lt;/form&gt; &lt;asp:DataGrid runat="server" id="FileList" Font-Name="Verdana" CellPadding="5" AutoGenerateColumns="False" AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-BackColor="Navy" HeaderStyle-ForeColor="White" HeaderStyle-Font-Size="15pt" HeaderStyle-Font-Bold="True"&gt; &lt;Columns&gt; &lt;asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name" HeaderText="File Name" target="_blank"/&gt; &lt;asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time" ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" /&gt; &lt;/Columns&gt; &lt;/asp:DataGrid&gt; </code></pre> <p>CS:</p> <pre><code>protected void btnShow_Click(object sender, EventArgs e) { ShowData(); } public void ShowData() { DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath("")); FileInfo[] info = dirInfo.GetFiles("*.pdf"); //Get FileInfo and Save it a FileInfo[] Array List&lt;Getfiles&gt; _items = new List&lt;Getfiles&gt;(); // Define a List with Two coloums foreach (FileInfo file in info) //Loop the FileInfo[] Array _items.Add(new Getfiles { Name = file.Name, LastWriteTime = file.LastWriteTime.ToString("MM/dd/yyyy") }); // Save the Name and LastwriteTime to List var tlistFiltered1 = _items.Where(item =&gt; item.Name.Contains(txtFilter.Text)); // Find the file that Contains Specific word in its File Name FileList.DataSource = tlistFiltered1; //Assign the DataSource to DataGrid FileList.DataBind(); } public class Getfiles { public string Name { get; set; } public string LastWriteTime { get; set; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload