.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Post New Resource Bookmark and Share   

Play all video formats in datalist using asp.net c# code from folder

Posted By:Ashutosh Jha       Posted Date: July 26, 2014    Points: 40    Category:    URL: http://www.dotnetspark.com  

Here you will see how to play all video formats in datalist using asp.net c# code from folder.
 

<asp:DataList ID="d1" runat="server">
<ItemTemplate>
<table>
<tr>
<td>
<video controls="controls" width="500" height="500" src='<%# Eval ("Name","videos/{0}") %>'></video>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>

public partial class videos : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindDataList();
}
}
protected void BindDataList()
{
DirectoryInfo dir = new DirectoryInfo(MapPath("~/videos"));
FileInfo[] files = dir.GetFiles();
ArrayList listItems = new ArrayList();
foreach (FileInfo info in files)
{
listItems.Add(info);
}
d1.DataSource = listItems;
d1 .DataBind(); 
}
}

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend