Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
<asp:GridView ID="GridView1" DataKeyNames="ID" OnRowDeleting="GridView1_RowDeleting" runat="server" AutoGenerateColumns="False">
<columns>
<asp:TemplateField HeaderText=" ID ">
<edititemtemplate>
<asp:TextBox ID="txtID" runat="server" Text='<%# Bind("ID") %>'>

<itemtemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Bind("ID") %>'>


<asp:TemplateField HeaderText=" Message ID ">
<edititemtemplate>
<asp:TextBox ID="txtMessageID" runat="server" Text='<%# Bind("MessageID") %>'>

<itemtemplate>
<asp:Label ID="lblMessageID" runat="server" Text='<%# Bind("MessageID") %>'>


<asp:TemplateField HeaderText=" Message Name ">
<edititemtemplate>
<asp:TextBox ID="txtMessageName" runat="server" Text='<%# Bind("MessageName") %>'>

<itemtemplate>
<asp:Label ID="lblMessageName" runat="server" Text='<%# Bind("MessageName") %>'>


<%--<asp:TemplateField HeaderText="English Message">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="200px" />
<itemtemplate>
<audio controls="controls">
<source src='English/<%# Eval("ID") %>' runat="server" type="audio/mpeg" />
<source src='English/<%# Eval("ID") %>' type="audio/ogg">
Your browser does not support this audio format.


--%>
<asp:TemplateField HeaderText="English Message">
<itemtemplate>
<object type="application/x-shockwave-flash" data='dewplayer-vol.swf?mp3=Announcement.ashx?Id=<%# Eval("Id") %>' width="240" height="20" id="dewplayer">
<param name="wmode" value="transparent" />
<param name="movie" value='dewplayer-vol.swf?mp3=Announcement.ashx?Id=<%# Eval("Id") %>' />



<%--<asp:TemplateField HeaderText=" English Message ">
<edititemtemplate>
<asp:TextBox ID="txtEnglishMessage" runat="server" Text='<%# Bind("EnglishMessage") %>'>

<itemtemplate>
<asp:Label ID="lblEnglishMessage" runat="server" Text='<%# Bind("EnglishMessage") %>'>

--%>
<asp:TemplateField HeaderText="Regional Message">
<itemtemplate>
<object type="application/x-shockwave-flash" data='dewplayer-vol.swf?mp3=Announcement.ashx?Id=<%# Eval("ID") %>' width="240" height="20" id="dewplayer">
<param name="wmode" value="transparent" />
<param name="movie" value='dewplayer-vol.swf?mp3=Announcement.ashx?Id=<%# Eval("ID") %>' />



<%-- <asp:TemplateField HeaderText=" Regional Message ">
<edititemtemplate>
<asp:TextBox ID="txtRegionalMessage" runat="server" Text='<%# Bind("RegionalMessage") %>'>

<itemtemplate>
<asp:Label ID="lblRegionalMessage" runat="server" Text='<%# Bind("RegionalMessage") %>'>

--%>
<asp:TemplateField HeaderText="Hindi Message">
<itemtemplate>
<object type="application/x-shockwave-flash" data='dewplayer-vol.swf?mp3=Announcement.ashx?Id=<%# Eval("ID") %>' width="240" height="20" id="dewplayer">
<param name="wmode" value="transparent" />
<param name="movie" value='dewplayer-vol.swf?mp3=Announcement.ashx?Id=<%# Eval("ID") %>' />



<%--<asp:TemplateField HeaderText=" Hindi Message ">
<edititemtemplate>
<asp:TextBox ID="txtHindiMessage" runat="server" Text='<%# Bind("HindiMessage") %>'>

<itemtemplate>
<asp:Label ID="lblHindiMessage" runat="server" Text='<%# Bind("HindiMessage") %>'>

--%>
<asp:CommandField ShowDeleteButton="True" />

<%-- <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />--%>



How can i play .wav file in that player on gridview the mp3 file is playing plz help me guys

What I have tried:

private void LoadData()
{
String CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "Select ID, MessageID, MessageName from SpecialAnnouncement order by ID desc";
cmd.Connection = con;
con.Open();
GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
con.Close();
}
}

public void ProcessRequest(HttpContext context)
{
int id = int.Parse(context.Request.QueryString["Id"]);
byte[] bytes;
byte[] bytes2;
byte[] bytes3;
string MessageID;
string MessageName;
string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "Select MessageID, MessageName, EnglishMessage, RegionalMessage, HindiMessage from SpecialAnnouncement where ID=@ID";
cmd.Parameters.AddWithValue("@ID", id);
cmd.Connection = con;
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
sdr.Read();
bytes = (byte[])sdr["EnglishMessage"];
bytes2 = (byte[])sdr["RegionalMessage"];
bytes3 = (byte[])sdr["HindiMessage"];
MessageID = sdr["MessageID"].ToString();
MessageName = sdr["MessageName"].ToString();
con.Close();
}
}
context.Response.Clear();
context.Response.Buffer = true;
context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + MessageID);
context.Response.ContentType = MessageName;
context.Response.BinaryWrite(bytes);
context.Response.End();
}

public bool IsReusable
{
get
{
return false;
}
}
Posted
Updated 31-Jul-18 22:42pm

1 solution

A massive code-dump wasn't enough to allow anyone to help you the last time you posted

I'm facing a issue for audio player in gridview[^]

and it still isn't enough this time. You need to do some debugging, at least explain what is working and what isn't. We have no idea if this is a problem with components on your machine, your browser settings, the rendering, your database, your network. Start with something simple and get the code working without the gridview using hard-coded urls and go from there.
 
Share this answer
 
Comments
Shahbaz435 1-Aug-18 4:45am    
in my code mp3 file is playing but wav file is not playing in the player on the gridview
Shahbaz435 1-Aug-18 5:50am    
i want wav file should be playing not a mp3 file plz help guys

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900