所以我有一个这样的网格视图:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="VideoID" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="VideoID" HeaderText="VideoID" ReadOnly="True" InsertVisible="False" SortExpression="VideoID" Visible="false"></asp:BoundField>
<asp:BoundField DataField="VideoEpisodeNumber" HeaderText="Episode" SortExpression="VideoEpisodeNumber"></asp:BoundField>
<asp:HyperLinkField DataTextField="VideoUrl" HeaderText="Video Url" DataTextFormatString="Link"/>
<asp:BoundField DataField="VideoDescription" HeaderText="VideoDescription" SortExpression="VideoDescription"></asp:BoundField>
</Columns>
</asp:GridView>
超链接域应该有视频链接!如何在用户点击时检索该链接? 提前谢谢你
答案 0 :(得分:0)
你可以试试这个:
<asp:HyperLinkField DataTextField="VideoUrl" HeaderText="Video Url" DataTextFormatString="Link" onclick="javascript:GetURL(this);"/>
function GetURL(sender) {
//Possibly sender should contain the object.
//if not
var parent = $find(sender.id);
var linkURL = parent.innerHTML;
}
答案 1 :(得分:0)
当您传播DataNavigationUrlFields时,将设置href属性。然后你应该能够拦截导航到相应的视频网址(假设解析客户端上的网址是你正在寻找的)
Gridview
<asp:HyperLinkField DataTextField="VideoUrl" HeaderText="Video Url" NavigateUrl="http://wwww.youtube.com" />
Javascript(jquery)
$(function () {
$("#myGridviewId a").on("click", interceptNavigation);
});
function interceptNavigation() {
alert($(this).attr("href"));
}