Avatar of newjeep19
newjeep19
Flag for United States of America asked on

using C# How to Import Data from a asp.net GridView to a CSV File

Can you import data from a CSV file and insert it into a ASP.NET GridView?  If so, can you provide a code example.

My code that I have so far: (which does not work):
 //CSV file input
        if (radDataInputFormat.SelectedValue == "3") -- I am allowing the user to select which data format that they want to use to insert/import data into the grid - this is for CSV
        {
            if (System.IO.File.Exists(fileUploadSI.FileName.ToString()))
            {
                System.IO.StreamReader fileReader = new StreamReader(fileUploadSI.FileName);

                //Check the end of file's content
                if (fileReader.Peek() != -1)
                {
                    string fileRow = fileReader.ReadLine();
                    string[] fileDateField = fileRow.Split(',');
                }
                //Close the StreamReader
                fileReader.Close();
            }
        }

Open in new window

C#ASP.NET

Avatar of undefined
Last Comment
Stephan

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Stephan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy