<asp:GridView ID="gvVideos" runat="server" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="1px" CellPadding="4" GridLines="Horizontal" AllowSorting=True Width="65%" OnRowDataBound="gvVideos_RowDataBound" OnRowCommand="gvVideos_RowCommand">
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#E3EAEB" Font-Names="Verdana" Font-Size="10pt" />
<EditRowStyle BackColor="#7C6F57" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" Font-Names="Verdana" Font-Size="8pt"
ForeColor="White" HorizontalAlign="Left" />
<AlternatingRowStyle BackColor="White" Font-Names="Verdana" Font-Size="10pt" />
<Columns>
<asp:ButtonField CommandName="LaunchVideo" Text="Launch Video" />
</Columns>
</asp:GridView>
Code
protected void gvVideos_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "LaunchVideo")
{
string URL="",VideoType="",sScript="";
URL = gvVideos.Rows[int.Parse(e.CommandArgument.ToString())].Cells[5].Text;
sScript = "<script language=javascript>" + " " + "window.open(" + "\"" + URL + "\"" +
",null," + "\" toolbar=no, menubar=no, directories=no, resizable=yes, location=yes, status=yes, scrollbars=0 " + "\"" +
"); window.resizeTo (screen.availWidth, screen.availHeight);window.moveTo(0,0);" + " </script>";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Startup", sScript, true);
}
}
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
Open in new window