Hi folks
I have two aspx pages that are part of a web site.
The first one (Sermons.aspx) contains a Gridview control that gets its data from a SQL Server Express 2005 DB and displays data from various fields in a view of a certain table. One of the fields contains the path and filename of a particular mp3 file that varies from one row to the next (varchar). It also has a button control in the last column.
Here is the source code for the first page:
1 <%@ Page Language="VB" MasterPageFile="~/CCFMaster1.master" AutoEventWireup="false" CodeFile="Sermons.aspx.vb" Inherits="Sermons" title="Sermons" %>
2 <asp:Content ID="Content1" ContentPlaceHolderID="bodyContentPlaceHolder" Runat="Server">
3
4 If you have a look below, there is a list of recent sermons by date. There
5 are also columns that include:<br />
6 <ul>
7 <li>the name of the speaker</li>
8 <li>topic</li>
9 <li>duration</li>
10 <li>download link</li>
11 <li>play button</li>
12 </ul>
13 <p>
14 </p>
15 <p>
16 </p>
17 <p></p>
18 <ul>
19 </ul>
20
21 If you right - click on the download link and select "Save Target as ...", you can
22 download the file to your computer.<asp:SqlDataSource ID="SqlDataSourceSermons" runat="server"
23 ConnectionString="<%$ ConnectionStrings:CCFWebSiteDBConnectionString1 %>"
24 OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [Sermon Date] AS Sermon_Date, [Speaker], [Topic], [Duration], [FileName], [File Name] AS File_Name FROM [vwSermons] ORDER BY [SermonDate]">
25 </asp:SqlDataSource>
26 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
27 DataSourceID="SqlDataSourceSermons" Style="z-index: 102; left: 234px; position: absolute;
28 top: 479px" AllowPaging="True" AllowSorting="True" Width="545px" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" Height="144px">
29 <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
30 <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
31 <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
32 <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
33 <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
34 <Columns>
35 <asp:BoundField DataField="Sermon_Date" HeaderText="Sermon_Date" SortExpression="Sermon_Date" />
36 <asp:BoundField DataField="Speaker" HeaderText="Speaker" SortExpression="Speaker" />
37 <asp:BoundField DataField="Topic" HeaderText="Topic" SortExpression="Topic" />
38 <asp:BoundField DataField="Duration" HeaderText="Duration" SortExpression="Duration" />
39 <asp:BoundField DataField="FileName" HeaderText="FileName" SortExpression="FileName"
40 Visible="False" />
41 <asp:BoundField DataField="File_Name" HeaderText="File_Name" SortExpression="File_Name"
42 Visible="False" />
43 <asp:HyperLinkField DataNavigateUrlFields="FileName" DataTextField="File_Name" HeaderText="Download" />
44 <asp:ButtonField ButtonType="Button" HeaderText="Play Sermon" Text="Play" />
45 </Columns>
46 </asp:GridView>
47
48 <ul>
49 </ul>
50 </asp:Content>
51
52
Here is the VB code associated with the same page:
1
2 Partial Class Sermons
3 Inherits System.Web.UI.Page
4
5 Public Sub New()
6
7 End Sub
8
9 Protected Overrides Sub Finalize()
10 MyBase.Finalize()
11 End Sub
12
13 Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
14 If e.CommandName = "Play" Then
15
16 Dim index As Integer = Convert.ToInt32(e.CommandArgument)
17
18 Dim row As GridViewRow = GridView1.Rows(index)
19
20 Server.Transfer("SermonsPlay.aspx")
21
22 End If
23 End Sub
24 End Class
25
The second page (SermonsPlay.aspx) has an embedded Quicktime control that at the moment has a hardcoded source mp3 file that plays successfully when I open that page.
Finally, this is the source code for the second page:
1 <%@ Page Language="VB" MasterPageFile="~/CCFMaster1.master" AutoEventWireup="false" CodeFile="SermonsPlay.aspx.vb" Inherits="SermonsPlay" title="Play Sermon" %>
2
3
4 <asp:Content ID="Content1" ContentPlaceHolderID="bodyContentPlaceHolder" Runat="Server">
5 <strong><em><span style="font-size: 24pt; text-decoration: underline">Play Sermon</span></em></strong><br />
6 <br />
7 <br />
8
9 <embed
10 src="Sermons/30Sept2007.mp3" align="middle">
11 </embed>
12 </asp:Content>
13
14
What I want to do is when a button on a particular row in the gridview control on the first page is clicked is for the first page to navigate to the next page and play the sound file. However, I cannot figure how to pass the path of the sound file to the second page so that the Quicktime control will play that mp3 file.
If anybody can explain how this can be done, I would really appreciate it.
Kind regards
Ross