Learn how to a build a cloud-first strategyRegister Now


Help directoryinfo/fileinfo

Posted on 2011-10-14
Medium Priority
Last Modified: 2012-05-12
Hello, with the attached code I'm populating a gridview that resides in another gridview with pictures from a folder on my site. The code does work and the gridveiw is populated with the filenames of the pictures. The problem is that the path to the images does not work when using the name attribute of the fileinfo. It is just the name of the image.

With my attached code how can I make it so the image path is added to the name attribute of the fileinfo?
Here is the pictures gridview that resides in the parent gridview:
                          <asp:GridView runat="server" ID="gvPictures" AutoGenerateColumns="false">
                                                    <asp:Image runat="server" ID="ImgSurveyPicture" ImageUrl='<%# Eval("Name") %>' AlternateText="CWT - Survey Image" />


Here is the code that runs in the rowdatabound of the parent gridview to find the correct pictures and populat the pictures gridview:

            'get controls to work with
            Dim Pictures As LinkButton = e.Row.FindControl("lbPictures")
            Dim Field As Label = e.Row.FindControl("lblField")
            Dim Area As Label = e.Row.FindControl("lblArea")
            Dim gvPictures As GridView = e.Row.FindControl("gvPictures")

            'create unique key that is also the folder name for the items pictures
            Dim Item As String = (Field.Text & " - " & Area.Text)

            'get path to the pictures
            Dim PicturesPath As String = ("~/SurveyImages/Survey - " & lblViewSurveyNumber.Text & "/" & Item)

            Dim file() As FileInfo

            Dim DirInfo As New DirectoryInfo(Server.MapPath(PicturesPath))
            Dim path As String = (Server.MapPath(PicturesPath))

            If DirInfo.Exists Then
                'fill the file array with the fileinfo, populate the gridview and show the pictures button if pictures exists for the item
                file = DirInfo.GetFiles()

                gvPictures.DataSource = file

                If file.Count > 0 Then
                    Pictures.Visible = True
                    Pictures.Visible = False
                End If

            End If

Open in new window

Question by:gogetsome
1 Comment
LVL 75

Accepted Solution

käµfm³d   👽 earned 2000 total points
ID: 36973216

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question