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
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