本文介绍了我的视频不玩(HOW)asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 当我尝试显示它时,我的数据库上有一个视频,但它没有。 这是我的代码 < asp:GridView ID = GridView1 runat = server BackColor = 白色 BorderColor = #DEDFDE BorderStyle = 无 BorderWidth = 1px CellPadding = 4 ForeColor = 黑色 GridLines = 垂直 > < 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 值 = true /> < param name = autostart 值 = true /> < / object > < / ItemTemplate > < / asp:templatefield > < / 列 > < pagerstyle backcolor = #F7F7DE forecolor = 黑色 horizo​​ntalalign = 右 /> < selectedrowstyle backcolor = #CE5D5A font-bold = True forecolor = 白色 /> < headerstyle backcolor = #6B696B font-bold = True forecolor = 白色 /> < alternatingrowstyle backcolor = White /> < / asp:GridView > 这是我的VideoHandler代码 <%@ WebHandler 语言 = C# 类 = VideoHandler %> 使用系统; 使用 System.Web; 使用 System.Data.SqlClient; 使用 System.Data; 使用 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]; 尝试 { connection.Open(); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default); if (reader.HasRows) { while (读者) .Read()) { context.Response.ContentType = reader [ Video_Name]的ToString(); context.Response.BinaryWrite(( byte [])reader [ 视频]); } } } 最后 { connection.Close(); } } public bool IsReusable { get { return 假; } } } 这是我背后的代码/> 受保护 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 表; } 请帮助。 gridview它只是在没有视频的情况下出现但视频名称和大小确实出现解决方案 尝试以下链接: http://videoplayer.codeplex.com/ [ ^ ] I have a video on my database when i try to display it, it does not.Here is my code<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<%@ 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 behindprotected 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 解决方案 try the following link:http://videoplayer.codeplex.com/[^] 这篇关于我的视频不玩(HOW)asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-26 19:14