forum

home / developersection / forums / to bind images in repeater using asp.net

To bind images in repeater using asp.net

Anonymous User 2192 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>


Updated on 01-Jun-2015

I am a content writter !

Can you answer this question?

Answer

1 Answers

Liked By