Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 11th, 2004, 04:38 PM
Authorized User
 
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can not display the image from database directly

Hi all,

I have a little problem to display a image( gif file) in my webpage.
The images are stored in sqlserver 2000 table and datatype as sqlserver.image ( actualy is byte[]). When I retrieve records from database, the image colum is return as a stream of data. On my webpage, I have the following

<asp:TemplateColumn HeaderText="Picture">
<ItemTemplate>
<img id=myImage border=0 runat="server" width=30 height=30
  src="<%#Databinder.Eval(Container.DataItem,"pictur e")%>" />
</ItemTemplate>

Insteads show the images, the column shows "System.Byte[]". I know src is not the right property in this case but I dont know how to fix it right now. Please help me to fix the problem.

Thanks



</asp:TemplateColumn>

 
Old October 11th, 2004, 11:36 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

You need to convert the binary to image using Response.BinaryWrite method.
Check the below article which explains how to retrieve the binary image from database and dispaly in DataGrid.Hope this will be useful..
http://www.dotnetbips.com/displayarticle.aspx?id=101

 
Old October 21st, 2004, 12:49 PM
Authorized User
 
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default



Since I retrieved pictures back form database directly, the codes below just display "System.byte[]" insteads of picture. How can I use Response.binaryWrite() in this case. I have tried

<%
Response.binaryWrite(Databinder.Eval(Container.Dat aItem,"picture"))
%>

but it gave me error: Name 'Container' is not declared. What does '#' in front Databinder means? How to fix this problem?

Thanks


*******************************************
This codes segment show "system.byte[]"

<asp:TemplateColumn HeaderText="Picture">
<ItemTemplate>
   <%#Databinder.Eval(Container.DataItem,"picture") %>
</ItemTemplate>
</asp:TemplateColumn>

*************************************************8

 
Old February 1st, 2005, 09:06 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

<%#> denotes DataBind expression block.We cannot use server side scripting in this block.And Container will be used in Databing Statements only.It denotes the parent control.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Access Restriction directly vinod_yadav1919 Javascript How-To 9 November 2nd, 2011 06:33 AM
How to display values in a struts jsp by directly naveenkumarg1 Forum and Wrox.com Feedback 0 August 1st, 2005 01:57 PM
display image from database fitchic77 .NET Framework 2.0 4 August 12th, 2004 07:44 PM
how to display OLE image object from database mushaimea Classic ASP Basics 3 July 27th, 2004 02:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.