troubleshooting Question

Details Column 'Name' does not belong to table .

Avatar of hmcgeehan
hmcgeehan asked on
15 Comments1 Solution2180 ViewsLast Modified:
In my code below I try to display the contents of a directory in a GridView but I get an error

Method GetDataColumn
Details Column 'Name' does not belong to table .
Stack Trace System. Data. DataRow. GetDataColumn (String columnName)
System. Data. DataRow. set_Item (String columnName, Object value)
AnPostWebParts. AnPostMediaCoverageAdminWebPart. GetListOfWaitingDocuments()
AnPostWebParts. AnPostMediaCoverageAdminWebPart. OnWebPartPreRender()
AnPostWebParts. BaseClasses. BaseWebPart. OnPreRender (EventArgs e)  

protected override void OnWebPartPreRender()

            //resultsGrid.Enabled = false;
            resultsGrid.DataSource = GetListOfWaitingDocuments();
            //resultsGrid.Enabled = true;


        private DataView GetListOfWaitingDocuments()

            //Get the directory specified by the user
            DirectoryInfo dirCustom = new DirectoryInfo(waitingFolder);

            // We'll store the file list here
            FileInfo[] filCustom;

            filCustom = dirCustom.GetFiles("*.xml");

            DataView myDataView = default(DataView);
            DataTable waitingDocuments = new DataTable();
            DataRow myDataRow = default(DataRow);

            // Loop through the file list
            foreach (FileInfo theFile in filCustom)
                myDataRow = waitingDocuments.NewRow();

                myDataRow["Name"] = theFile.Name;
                myDataRow["Length"] = theFile.Length;
                myDataRow["LastWriteTime"] = theFile.LastWriteTime;
                myDataRow["Extension"] = theFile.Extension;

            myDataView = waitingDocuments.DefaultView;
            return myDataView;

        // ASP.NET controls
        Label headingLabel;
        GridView resultsGrid;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros