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" %>
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
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
27
28 </div>
29 </form>
30 </body>
31 </html>
32
Cheers
Sheraz