C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Playable Song List


Posted Date: 09 Jan 2008    Resource Type: Code Snippets    Category: ASP.NET GridView

Posted By: Mohan       Member Level: Gold
Rating:     Points: 10



This sample uses a Gridview, with a HyperLink Field, to show how to simply create a song download list. In this sample, since it's set up just to quickly stream/play the files, the target file is '.m3u'.

To make it downloadable, change the extension to '.mp3' for your files. The only bad part about that, is most people's systems are setup to automatically run any filetype it recognizes, so it will try to play the song, even after the long MP3 download. You can prompt the users to right-click and choose the 'Save Target As' option.

Note, too, that here, I've not included the extension or the path in the database - just the filename. There's no really good reason I didn't include the extension. But this shows how to use the extension with the DataNavigateUrlFormatString of the Gridview. Also, by not hardcoding the path in the database, if you decide to move it to a different location later, you only need to change it in one place, instead of in every row of the table.



<%@ Page Language="VB" %>
<html>
<head>
<title>Music Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Your_dbConnectionString %>"
SelectCommand="SELECT [id], [Title], [Filename], [Genre], [Author] FROM [SongTest]">
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
SortExpression="id" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Genre" HeaderText="Genre" SortExpression="Genre" />
<asp:BoundField DataField="Author" HeaderText="Author" SortExpression="Author" />
<asp:HyperLinkField DataNavigateUrlFields="Filename"
DataNavigateUrlFormatString="http://YourPath/{0}.m3u"
DataTextField="Filename" DataTextFormatString="Get it Now" HeaderText="Download"
Target="_blank" />
</Columns>
</asp:GridView>

</div>
</form>
</body>
</html>





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Making playlist  .  Gridview  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Creating a Datatable Manually
Previous Resource: Select / Deselect All records functionality inside GridView.
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET GridView


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use