msout
asked on
Display Images in DataList Control using the path stored in SQL Server database
I try to Display Images in DataList Control using the path stored in SQL Server database.
The images stored in the separate folder called "Images" on web server & I store the image path in the Database
I use sqldatasource to show the data:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:BLSDBCon nectionStr ing1 %>"
SelectCommand="SELECT * FROM [Employees] ORDER BY [LastName]">
</asp:SqlDataSource>
I can show images in the gridview but on the web page we need to show three images in the row. So I need to use datalist and not the gridview.
This is my code:
<asp:DataList ID="dtList"
runat="server"
DataSourceID="SqlDataSourc e1"
HorizontalAlign="Justify"
RepeatColumns="3"
RepeatDirection="Horizonta l" >
<ItemTemplate>
EmployeeId:
<asp:Label ID="EmployeeIdLabel"
runat="server"
Text= '<%#DataBinder.Eval(Contai ner.DataIt em, "EmployeeId")%>'></asp:Lab el>
<br />
FirstName:
<asp:Label ID="FirstNameLabel"
runat="server"
Text='<%#DataBinder.Eval(C ontainer.D ataItem,"F irstName") %>' />
<br />
MidInit:
<asp:Label ID="MidInitLabel"
runat="server"
Text='<%#DataBinder.Eval(C ontainer.D ataItem,"M idInit") %>' />
<br />
LastName:
<asp:Label ID="LastNameLabel"
runat="server"
Text='<%#DataBinder.Eval(C ontainer.D ataItem,"L astName") %>' />
<br />
Unit:
<asp:Label ID="UnitLabel"
runat="server"
Text='<%#DataBinder.Eval(C ontainer.D ataItem,"U nit") %>' />
<br />
PictureFileName:
<asp:Label ID="PictureFileNameLabel" runat="server"
Text='<%#DataBinder.Eval(C ontainer.D ataItem,"P ictureFile Name") %>' />
<br />
<asp:Image ID="ImageID" runat="server" Width="100px"
ImageUrl='<%# Eval("ImagePath") %>' />
</ItemTemplate>
</asp:DataList>
All records show except the image. It is empty.
How can I correct it?
Please, help.
The images stored in the separate folder called "Images" on web server & I store the image path in the Database
I use sqldatasource to show the data:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:BLSDBCon
SelectCommand="SELECT * FROM [Employees] ORDER BY [LastName]">
</asp:SqlDataSource>
I can show images in the gridview but on the web page we need to show three images in the row. So I need to use datalist and not the gridview.
This is my code:
<asp:DataList ID="dtList"
runat="server"
DataSourceID="SqlDataSourc
HorizontalAlign="Justify"
RepeatColumns="3"
RepeatDirection="Horizonta
<ItemTemplate>
EmployeeId:
<asp:Label ID="EmployeeIdLabel"
runat="server"
Text= '<%#DataBinder.Eval(Contai
<br />
FirstName:
<asp:Label ID="FirstNameLabel"
runat="server"
Text='<%#DataBinder.Eval(C
<br />
MidInit:
<asp:Label ID="MidInitLabel"
runat="server"
Text='<%#DataBinder.Eval(C
<br />
LastName:
<asp:Label ID="LastNameLabel"
runat="server"
Text='<%#DataBinder.Eval(C
<br />
Unit:
<asp:Label ID="UnitLabel"
runat="server"
Text='<%#DataBinder.Eval(C
<br />
PictureFileName:
<asp:Label ID="PictureFileNameLabel" runat="server"
Text='<%#DataBinder.Eval(C
<br />
<asp:Image ID="ImageID" runat="server" Width="100px"
ImageUrl='<%# Eval("ImagePath") %>' />
</ItemTemplate>
</asp:DataList>
All records show except the image. It is empty.
How can I correct it?
Please, help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Never mind! I just deleted hiperlink and it shows only a picture!
Great! Happy to help.
ASKER
images/Aaron Bitler.jpg - this is the ImagePath. I cannot delete the extension - .jpg because it won't show the picture. How can I show only the picture without the "images/Aaron Bitler.jpg "