Serious problem with datagrid

esposito

Centurion
Joined
Jul 11, 2003
Messages
103
Location
Perugia - Italy
Hello, I have a serious problem with a datagrid control that is bound to an Access database.

I have put my database in a subfolder of the "admin" folder called "datastore".

Inside the "admin" folder, I have also put another folder called "attachments".

In a field of my Access database, I have stored the path of my attached files that I upload onto the server when I log on as a designer.

This is the code I have used in the upload button:

Visual Basic:
Sub btnLoad00_Click(sender As Object, e As EventArgs)

     If Not (fileControl00.PostedFile Is Nothing) Then

              Try

              Dim FileDest As String

              Dim myPath As String = fileControl00.value

              Dim myFileName As String = System.IO.Path.GetFileName(myPath)

              FileDest = "attachments" & "/" & myFileName

              hypFileDest.Text = (Server.MapPath(FileDest))

              fileControl00.PostedFile.SaveAs((hypFileDest.Text))

       End If

End Sub

As you can see, I add the folder name ("attachments") to the uploaded file name, so I can keep track of the entire path.

Now, I have bound two datagrids to my database, one is in the "admin" folder and the other is in the root folder. Each datagrid contains a hyperlink field to the attached file.

In the datagrid in the "admin" folder I have no problem launching the attached file when I click on the hyperlink, because the path retrieved from the database is correct.

Unfortunately, the datagrid in the root folder does not allow me to launch the attached files, because the path I click on does not contain the "admin" subfolder name.

So, my question is, how can I intervene in the datagrid in the root folder so that when I click on the hyperlink field I can add "admin" before the path retrieved from the database?

The code I use to populate my datagrid is the following:

Visual Basic:
          Dim MySQL as string = "Select * from mytable"

          Dim myConn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & server.mappath("datastore/database.mdb") & ";")
          Dim ds as DataSet=New DataSet()
          Dim Cmd as New OleDbDataAdapter(MySQL,MyConn)

          Cmd.Fill(ds,"mytable")
          dgTabella.Datasource=ds.Tables("mytable").DefaultView
          dgTabella.DataBind()
          MyConn.Close()

Any help will be greatly appreciated.

TIA
 
Back
Top