troubleshooting Question

Display Images in DataList Control using the path stored in SQL Server database

Avatar of msout
msout asked on
Web DevelopmentASP.NET
4 Comments1 Solution1980 ViewsLast Modified:
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:BLSDBConnectionString1 %>"
            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="SqlDataSource1"
            HorizontalAlign="Justify"
            RepeatColumns="3"
            RepeatDirection="Horizontal" >
           
            <ItemTemplate>
                EmployeeId:
                <asp:Label ID="EmployeeIdLabel"
                    runat="server"
                    Text= '<%#DataBinder.Eval(Container.DataItem, "EmployeeId")%>'></asp:Label>
                <br />
                FirstName:
                <asp:Label ID="FirstNameLabel"
                    runat="server"
                    Text='<%#DataBinder.Eval(Container.DataItem,"FirstName") %>' />
                <br />
                MidInit:
                <asp:Label ID="MidInitLabel"
                    runat="server"
                    Text='<%#DataBinder.Eval(Container.DataItem,"MidInit") %>' />
                <br />
                LastName:
                <asp:Label ID="LastNameLabel"
                    runat="server"
                    Text='<%#DataBinder.Eval(Container.DataItem,"LastName") %>' />
                <br />
                Unit:
                <asp:Label ID="UnitLabel"
                    runat="server"
                    Text='<%#DataBinder.Eval(Container.DataItem,"Unit") %>' />
                <br />
                PictureFileName:
                <asp:Label ID="PictureFileNameLabel" runat="server"
                    Text='<%#DataBinder.Eval(Container.DataItem,"PictureFileName") %>' />
                <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.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros