Reputation: 3748
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="SqlDataSourceVideo" >
<Columns>
<asp:BoundField DataField="VideoUrl" HeaderText="VideoUrl"
SortExpression="VideoUrl" />
<asp:BoundField DataField="ID" HeaderText="ID"
SortExpression="ID" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="Video_Name" HeaderText="Video_Name"
SortExpression="Video_Name" />
<asp:CommandField ShowDeleteButton="True" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="ButtonPlay" runat="server" CommandName="Play"
CommandArgument='<%# DataBinder.Eval(Container.DataItem,"VideoUrl") %>'
Text="Play" OnClientClick="playVideo()"></asp:Button>
JavaScript code for play URL:
<script type="text/javascript" language="javascript">
function playAudio(URL){
if (URL != "")
{
document.Player.filename = URL;
document.getElementsByName("mediaPlayer").src=URL;
document.getElementsByName("mediaPlayer").play();
document.Player.showcontrols = true;
document.Player.height = 40;
document.Player.play();
}
}
</script>
Can anyone tell me how to get URL value from gridview? Thanks in advance.
Upvotes: 0
Views: 443
Reputation: 7218
Try this,
<asp:Button ID="ButtonPlay" runat="server" CommandName="Play"
CommandArgument='<%# DataBinder.Eval(Container.DataItem,"VideoUrl") %>'
Text="Play"
OnClientClick='<%# DataBinder.Eval(Container.DataItem,"VideoUrl", "playVideo('{0}')") %>'>
</asp:Button>
Upvotes: 1
Reputation: 2965
OnClientClick='<%# EVAL("VideoUrl", "return playAudio({0})") %>'/>
use this in your button .Hope it helps.
Upvotes: 0
Reputation: 83356
I would change your BoundField into a TemplateField
<asp:TemplateField SortExpression="VideoUrl" HeaderText="Video Url">
<span class='videoUrl<%# DataBinder.Eval(Container, "RowIndex") %>'><%# Eval("VideoUrl") %></span>
</asp:TemplateField>
Then, to get the url from row three:
var span = document.getElementsByClassName("videoUrl3")[0];
var url = span.textContent ? span.textContent : span.innerHTML;
Upvotes: 1