I am using DataGrid:
<asp:DataGrid runat="server" ID="articleList" UseAccessibleHeader="true" AutoGenerateColumns="false" AlternatingItemStyle-BackColor="#EEEEEE" HeaderText="File Name">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="DirectoryName" DataTextField="Name" HeaderText="File Name" />
<asp:BoundColumn DataField="LastWriteTime" HeaderText="Modified" ItemStyle-HorizontalAlign="Center" DataFormatString="{0:f}" />
<asp:BoundColumn DataField="Length" HeaderText="Size" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:#,### bytes}" />
<asp:BoundColumn DataField="Extension" HeaderText="Type" ItemStyle-HorizontalAlign="Left" />
</Columns>
</asp:DataGrid>
Here is my code page:
protected void Page_Load(object sender, EventArgs e)
{
DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath("examfilemanager"));
articleList.DataSource = dirInfo.GetFiles();
articleList.DataBind();
}
Files inside this directory:
01.jpg
02.jpg
MyDoc.doc
I am trying to provide a direct link for a click to click and load it. It seems that the only links I can get is the name "01.jpg", which is inside the document manager.
The Name property of the file information properties returns only the name. (01.jpg)
Link href to link 01.jpg, I need it to be examfilemanager/01.jpg, how can I make it possible?
source
share