日期:2014-05-17  浏览次数:20669 次

GridView 绑定视频播放器
C# code

<asp:GridView ID="gvVideo" runat="server" AutoGenerateColumns="false" DataKeyNames="FilePath" >
                    <Columns>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <table>
                                    <tr>
                                        <td>
                                            <div id="CuPlayer" style="margin-top: 20px;">
                                                <strong>酷播迷你 (CuPlayerMiniV1.0)</strong>
                                            </div>
                                        </td>
                                        <td>
                                            视频标题:<%#Eval("WorksName")%>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>


在绑定GridView时,要显示视频和视频标题,现在调用js显示视频,代码如下:
JScript code

var so = new SWFObject("/js/CuPlayerMiniV20_Black_S.swf", "CuPlayer", "120", "85", "9", "#000000");
    so.addParam("allowfullscreen", "true");
    so.addParam("allowscriptaccess", "always");
    so.addParam("wmode", "opaque");
    so.addParam("quality", "high");
    so.addParam("salign", "lt");
    so.addVariable("CuPlayerFile", "<%=url%>");
    so.addVariable("CuPlayerShowImage", "false");
    so.addVariable("CuPlayerWidth", "120");
    so.addVariable("CuPlayerHeight", "85");
    so.addVariable("CuPlayerAutoPlay", "false");
    so.addVariable("CuPlayerAutoRepeat", "false");
    so.addVariable("CuPlayerShowControl", "true");
    so.addVariable("CuPlayerAutoHideControl", "false");
    so.write("CuPlayer");


如今<%=url%>这个参数的调用是我在后台写死的。所以如果有三条数据,只有一条数据是有值的。
请问GridView中如何动态绑定这个视频的url呢。

------解决方案--------------------
<%=url%> 这个值你都可以在后台绑定,为什么不可以在后台判断后再绑定呢?
------解决方案--------------------
后台帮定

class.vidio=swf("ada.swf","","")


送要主个方法拿来改改


C# code


 /// <summary>
        /// swf格式
        /// </summary>
        /// <param name="url"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <returns></returns>
        private static string swf(string url, int width, int height)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();


            sb.Append("<OBJECT   codeBase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\"   ");
            sb.Append("   height=\"" + height + "\"   width=\"" + width + "\"   >");
            sb.Append("<PARAM   NAME=\"FlashVars\"   VALUE=\"\">");
            sb.Append("<PARAM   NAME=\"Movie\"   V