473,799 Members | 2,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Displaying Image from DB inside a Gridview

2 New Member
Hi folks,

Been struggling with this little puzzle.

I am reading the MemberInfo table for the ClubStarterKit, the table includes the Avatar for the User.

I would like to display the Avatar as an image in a databound element, in this case I am resorting to Gridview although I would prefer datalist or something simpler.

<code>

<asp:SqlDataSou rce ID="SqlDataSour ce2" runat="server" ConnectionStrin g="<%$ connectionStrin gs:ClubSiteDB %>"

SelectCommand=" SELECT aspnet_Users.Us erName, aspnet_Users.Us erId, Attendance.numo fguest, MemberInfo.avat ar FROM Attendance INNER JOIN aspnet_Users ON Attendance.memb er = aspnet_Users.Us erId INNER JOIN MemberInfo ON Attendance.memb er = MemberInfo.memb erid WHERE (Attendance.eve ntid = @id)">
<SelectParamete rs>
<asp:QueryStrin gParameter DefaultValue="1 " Name="id" QueryStringFiel d="EventId" Type="Int32" />
</SelectParameter s>
</asp:SqlDataSour ce>

<asp:GridView ID="GridView1" runat="server" AllowPaging="Tr ue"
DataSourceID="S qlDataSource2" CellPadding="4" ForeColor="#333 333" GridLines="None " AutoGenerateCol umns="False" DataMember="Def aultView">
<FooterStyle BackColor="#990 000" Font-Bold="True" ForeColor="Whit e" />
<Columns>
<asp:BoundFie ld DataField="User Name" HeaderText="Use rName" SortExpression= "UserName" />
<asp:BoundFie ld DataField="numo fguest" HeaderText="Num ber of Guests" SortExpression= "numofguest " />
<asp:BoundFie ld DataField="avat ar" HeaderText="ava tar" SortExpression= "avatar" >
</asp:BoundField>
</Columns>

<RowStyle BackColor="#FFF BD6" ForeColor="#333 333" />
<SelectedRowSty le BackColor="#FFC C66" Font-Bold="True" ForeColor="Navy " />
<PagerStyle BackColor="#FFC C66" ForeColor="#333 333" HorizontalAlign ="Center" />
<HeaderStyle BackColor="#990 000" Font-Bold="True" ForeColor="Whit e" />
<AlternatingRow Style BackColor="Whit e" />
</asp:GridView>

</code>

When I configure the SqlDatasource and test the query it actualy shows the Image in the TestQuery Results window. But when I run my page the Gridview populates with the other columns but in the AVATAR it shows byte[]

What should I do to get this working?
Mar 19 '06 #1
1 2640
Metalore
1 New Member
Hi all,

I am also trying to display an image from DB to gridview. Has anyone done this and can advise on how to do it?

Currently, I have one table which has ID, name, photo attributes for each record. The gridview is currently displaying ID and name only :( The photo is stored as an image data type in SQL server 2005 express.

Any help would be greatly appreciated

Tony
Oct 16 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2366
by: CLEAR-RCIC | last post by:
I have several images i want to display in an ASP.Net application. The images are being passed to me in binary format from another application. Is there a good way to write them directly to an HMTL page without having to save them to the server and create a URL to the virtual directory? FYI: I currently am doing this with just single images. I do a Response.BinaryWrite(byte) to display the one image. The advantage is that I never...
18
6526
by: Auto | last post by:
Hello, I would like to know how do display an image into a Gridview (ASP.NET 2.0) taken directly from a DataBase, NOT using an URL, like described in this article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/GridViewEx06.asp I have NO URL, i have the binary image inside the DB, like the field "Photo" in the table "Employees" of the "NWIND.MDB" DataBase.
3
2522
by: velu | last post by:
Asp.Net 2 I am trying to display Image from Northwind Database. I ran a queary "SELECT CategoryID, CategoryName, Description, Picture FROM Categories" but the Dataview displayes all the fields except Picture. so i add a Imagefield to display images..but now i get cross icon.. below is the code. correct me where i am wrong....
1
6791
by: VMI | last post by:
I'm working on an ecommerce-type we app, and I would like to save/retrieve image information into my sql server DB. If I save the file path in my table, how can I use that info to display the image in the gridview? IS there a better way? Since there are so many products, I don't want to save the actual image into the DB. I just want to save some info that I can later reference when I fill up my grid. What's the best way to do this? ...
3
1466
by: aSoundMind | last post by:
Hello Guys, I am not sure is this a common problem. I can't display image which in a gridview to excel or word. I have not try on pdf or web but surely this annoy me. I tried to google it and the best I can found is this code which mentioned something tat it is due to excel limitation and so we need to use absolute path.
10
5773
by: gnewsgroup | last post by:
I've googled and tried various approaches, but could not resolve this problem. The article at MSDN: Displaying Images in a GridView Column only presents a simple case where all data (including the images) of the gridview come from a single table/datasource. Here is my situation. In my web application, I need to display customer bills info in a gridview. Customer names and contact info are from the Customer table.
2
2884
by: Raiders8180 | last post by:
Hi, I'm new to the community (1st post) so I hope I didn't leave anything out. I have a gridview (grdPics) created with 1 Imagefiled (picname) which contains the URL to where the image is stored. asp code... <asp:GridView ID="grdPics" runat="server" Height="136px" Style="z-index: 133; left: 32px; position: absolute; top: 600px" Width="464px" AutoGenerateColumns="False"> <Columns> <asp:ImageField...
1
1866
by: BillGatesFan | last post by:
This is probably my second time using a GridView control and I cannot not figure out how to display HTML inside a datacolumn. Can somehow help me? I would be very surprised if it cannot be done. I want to display an image with a link to it in a data column For example: <a href='http://www.google.com'><img src='http://..../icon.jpg'
3
3087
by: anjali5 | last post by:
Hello Everyone, I want to display an image in my gridview. The only thing is my datatabse table is returning true if there is an image and false if there is no image and I am binding my gridview with dataset. This dataset contains a colun called hasAttachments as true or false. Is it possible to display image in the image field? This image does not exsist in the database. I have image in the image folder in my application code. ...
0
10488
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.