image field and sqldatasource

Y

yefei

I need to display images in a SQL database using a gridview
I search some examples, what they did is very simple
add an image field, then set the folowing properties

<asp:imagefield dataimageurlfield="LastName"
dataimageurlformatstring="~\Images\{0}.jpg"
alternatetext="Employee Photo"
nulldisplaytext="No image on file."
headertext="Photo"
readonly="true"/>
<asp:boundfield datafield="FirstName"
headertext="First Name"/>
<asp:boundfield datafield="LastName"
headertext="Last Name"/>
if i set the datasource of the gridview to a sqldatasource with the
folowing commands
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:MyConnectionString
%>"
SelectCommand="SELECT [No_], [Picture], [Picture No_] AS Picture_No_
FROM [My Company$Item] ORDER BY [No_]

the 'Picture' is the image field, the Picture_No is used to identify
the picture, the No_ is the name of our product

and i have the following setting on my image field

<asp:ImageField DataAlternateTextField="Picture_No_"
DataImageUrlField="Picture_No_"
HeaderText="Picture" DataImageUrlFormatString="~\Image\{0}.gif">
</asp:ImageField>

i saw some example uses accessDataSource
but i think the image field should also work with sqldatasource
but when i render the gridview, the images are the Picture_No with red
cross

i am using the Visual Web Developer 2005 Express Edition in C#.Net

can someone point out what's wrong with my property settings?
especially regards to SQL Database Server
 
Y

yefei

I found that people are talking about the ImageUrl instead of the image
in the database

that is what stored in the database is the URL of the image instead of
the image itself

But I have no idea how an image is stored in a SQL server
 
Y

yefei

thanks very much
I am using Visual Web Developer 2005 Express edition, which does not
have DataGrid control, instead it has GridView control
the GridView control doesnot have the ItemBound event
and all the events, no one is associated with an item,

the DataList control in VWD has the itemBound event, but C#.net have no
CType function
So is there a way I can do with GridView control, or DataList control
or some hints to declare and display a DataGrid object in codes?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top