dotnet 2 gridview problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DavyC

    dotnet 2 gridview problem

    I'm populating a gridview (docList) with document info from a network
    folder like so:

    Sub Show_Files(ByVa l inputDir As String)
    Dim strFileNamePath As String = inputDir
    Dim dirInfo As DirectoryInfo = New DirectoryInfo(s trFileNamePath)
    Dim aFiles As FileInfo() = dirInfo.GetFile s("*.doc")
    Array.Sort(aFil es, New CompareFileInfo Entries
    (CompareByOptio ns.LastWriteTim e))
    docList.DataSou rce = aFiles
    docList.DataBin d()
    End Sub

    However when I try to delete a file like so:

    Sub Row_Deleting(By Val Src As Object, ByVal Args As
    GridViewDeleteE ventArgs)
    If File.Exists(e.K eys("Name").ToS tring) Then
    File.Delete(e.K eys("Name").ToS tring)
    End If
    End Sub

    I get the following message:

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.NullRefe renceException: Object reference not
    set to an instance of an object.

    Source Error:

    Line 25:
    Line 26: Sub Row_Deleting(By Val Src As Object, ByVal Args As
    GridViewDeleteE ventArgs)
    Line 27: If File.Exists(Arg s.Keys("Name"). ToString) Then
    Line 28: File.Delete(Arg s.Keys("FullNam e").ToString )
    Line 29: End If

    This is driving me nuts, I've tried everything I know to try and get a
    file name from the GridViewDeleteE ventArgs to delete the file but with no
    success. Help!

    Davy
Working...