Hi alhamd,
Check the code with master page.
HTML
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Text" HeaderText="FileName" />
<asp:TemplateField>
<ItemTemplate>
<audio controls style='display: <%# Eval("Value").ToString().ToLower() == ".mp3" ? "block" : "none" %>'>
<source src='<%# ResolveUrl(Eval("Text").ToString()) %>' type='audio/mpeg' />
</audio>
<video controls style='display: <%# Eval("Value").ToString().ToLower() == ".mp4" ? "block" : "none" %>'
src='<%# ResolveUrl(Eval("Text").ToString()) %>' width="200" height="250" loop="true" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Content>
Namespaces
using System.IO;
Code
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string[] filePaths = Directory.GetFiles(Server.MapPath("~/Files/"));
List<ListItem> files = new List<ListItem>();
foreach (string filePath in filePaths)
{
files.Add(new ListItem("~/Files/" + Path.GetFileName(filePath), Path.GetExtension(filePath)));
}
GridView1.DataSource = files;
GridView1.DataBind();
}
}
Screenshot