Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a video on my database when i try to display it, it does not.

Here is my code
C#
<asp:GridView ID="GridView1" runat="server" BackColor="White"
       BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4"
       ForeColor="Black" GridLines="Vertical">
       <footerstyle backcolor="#CCCC99" />
       <rowstyle backcolor="#F7F7DE" />
       <Columns>
           <asp:templatefield>
               <ItemTemplate>
                   <object id="player" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"
                       height="170" width="500">
                       <param name="url" value='<%# "VideoHandler.ashx?id=" + Eval("Video_Number") %>'/>
                       <param name="showcontrols" value="true" />
                       <param name="autostart" value="true" />
                   </object>
               </ItemTemplate>
           </asp:templatefield>
       </Columns>
       <pagerstyle backcolor="#F7F7DE" forecolor="Black" horizontalalign="Right" />
       <selectedrowstyle backcolor="#CE5D5A" font-bold="True" forecolor="White" />
       <headerstyle backcolor="#6B696B" font-bold="True" forecolor="White" />
       <alternatingrowstyle backcolor="White" />
   </asp:GridView>

this is my VideoHandler code
C#
<%@ WebHandler Language="C#" Class="VideoHandler" %>

using System;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

public class VideoHandler : IHttpHandler 
{
    
    public void ProcessRequest (HttpContext context) 
    {
        string connectionString = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;

        SqlConnection connection = new SqlConnection(connectionString);
        SqlCommand cmd = new SqlCommand("SELECT Video, Video_Name FROM VIDEO WHERE Video_Number = @id", connection);
        cmd.Parameters.Add("@id", SqlDbType.Int).Value = context.Request.QueryString["Video_Number"];
        try
        {
            connection.Open();
            SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    context.Response.ContentType = reader["Video_Name"].ToString();
                    context.Response.BinaryWrite((byte[])reader["Video"]);
                }
            }
        }
        finally
        {
            connection.Close();
        }
    }
 
    public bool IsReusable 
    {
        get {
            return false;
        }
    }

}


And this is my code behind

C#
protected void Page_Load(object sender, EventArgs e)
    {
        //lblname.Text = Session["name"];
        GridView1.DataSource = GetVideoInfo();
        GridView1.DataBind();
    }
    private DataTable GetVideoInfo()
    {
        string connectionString = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
        SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM VIDEO", connectionString);
        DataTable table = new DataTable();
        adapter.Fill(table);
        return table;
    }


Please help.
The gridview it just appear without the video but Video name and size it does appear
Posted

1 solution

try the following link:

http://videoplayer.codeplex.com/[^]
 
Share this answer
 

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