Users Pricing

forum

Home Forums To bind images in repeater using asp.net – MindStick

To bind images in repeater using asp.net

Anonymous User 2418 01 Jun 2015
in this sample i want to bind the image from local drive to repeater but not bind properly.


string[] filePaths = Directory.GetFiles("D:\\Users\\Images\\Pictures\\");
            List<ListItem> files = new List<ListItem>();
            foreach (string filePath in filePaths)
            {
                string fileName = Path.GetFileName(filePath);
                files.Add(new ListItem(fileName, @"D:\Users\Images\Pictures\" + fileName)); //i can get image name  --D:\Users\Images\Pictures\flight.jpg
            }
            Repeater1.DataSource = files;
            Repeater1.DataBind();
 <asp:Repeater ID="Repeater1" runat="server">
                        <ItemTemplate>
                            <li>
                                <img src='<%# DataBinder.Eval(Container.DataItem,"Value") %>' title='<%# (DataBinder.Eval(Container.DataItem,"Text").ToString()).Split('.')[0].ToString() %>' alt=""></li>
                        </ItemTemplate>
                    </asp:Repeater>


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md