Member Avatar for mrkm1188

I have a GridView that is populated with information froma sql table. The first column of the table has a number (0,1,2,etc.) that corresponds to a folder on the network that contains multiple documents. After the table is generated with all the information from the sql table, I want to add a column that contains link to each document in the folder on the network. For example, the first row of the gridview has number "3" in the first cell, so i want the last cell of the row to have two hyperlinks to two separate word documents that reside on the network. This is the code I have so far but when I run the program the cells are empty. The hyperlinks do not show up. Any help is greatly appreciated

Protected Sub ResultsGridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles ResultsGridView.RowDataBound

            Dim contractNumber As String = e.Row.Cells(0).Text.ToString
            Dim pathToFiles As String = "\\eng\common\Contract Management\" & contractNumber

            If (System.IO.Directory.Exists(pathToFiles)) Then
                Dim dir As DirectoryInfo = New DirectoryInfo(pathToFiles)
                Dim files As FileInfo() = dir.GetFiles()

                For Each file In files 'copy to Files column
                    Dim link As New HyperLink
                    link.Text = file.Name
                    link.NavigateUrl = file.FullName
                    e.Row.Cells(7).Controls.Add(link)
                Next
            End If
    End Sub

Hi

Are you sure that the path to the files is correct? Have you tried to step through the code and see if you are even entering the block of code that determines if the directory exists?

My thoughts are that it does not as I have tested your scenario and the links are added to the GridView successfuly using your code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.