Wrox Programmer Forums
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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 August 30th, 2007, 10:36 PM
Authorized User
Join Date: May 2007
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
Default Display image in gridview


I am trying to display the Picture field of the table categories from the Northwind database. I have tried to do it by both ways:

Using the Templete Field ( by placing the image control).
By adding a new column and then bind it from the Picture field of the categories table.
But both methods only show the path of the image but didn't actually load the image, donno why...?

The code through adding a new column (selecting type: image field and Bound field: picture ) is given bellow:

1 <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="DisplayPictire.aspx.vb" Inherits="GridViewRetriefValues.DisplayPictire" %>
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5 <html xmlns="http://www.w3.org/1999/xhtml" >
6 <head runat="server">
7 <title>Untitled Page</title>
8 </head>
9 <body>
10 <form id="form1" runat="server">
11 <div>
12 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
13 SelectCommand="SELECT [CategoryID], [CategoryName], [Description], [Picture] FROM [Categories]">
14 </asp:SqlDataSource>
15 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID"
16 DataSourceID="SqlDataSource1" Style="position: relative">
17 <Columns>
18 <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False"
19 ReadOnly="True" SortExpression="CategoryID" />
20 <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" />
21 <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
22 <asp:ImageField DataImageUrlField="Picture">
23 </asp:ImageField>
24 </Columns>
25 </asp:GridView>
26 &nbsp; &nbsp;
28 </div>
29 </form>
30 </body>
31 </html>


Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload image-create & save thumbnail-display image angshujit ASP.NET 2.0 Professional 6 July 11th, 2013 10:34 PM
how to display the GridView. kcsathish ASP.NET 2.0 Basics 1 July 23rd, 2008 04:08 AM
gridview image display Sheraz Khan ASP.NET 2.0 Basics 1 September 2nd, 2007 11:37 PM
GridView doesn't display bnorg ASP.NET 2.0 Professional 1 December 1st, 2006 10:14 PM
How to Display the image from the image field. mikeparams SQL Server 2000 1 October 29th, 2004 02:23 AM

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