I have some large data files (7 fields x 7,000 records) in an ASCII/text file format that I would like to display on a website. Is there a way to get that data into a GridView or do I have to read it into an Access, SQL, object, site map, or xml file format first

Thank you,


Re: Windows Forms Data Controls and Databinding Text file in a GridView

Guang-Ming Bian - MSFT

hi David

Because your ASCII/text file format, you could only read line by line, like the code below, you can read all the data into a datatable.

Code Snippet

using (StreamReader sr = new StreamReader("TestFile.txt"))
String line;
// Read and display lines from the file until the end of
// the file is reached.
DataTable dt=new DataTable();
while ((line = sr.ReadLine()) != null)
DataRow row=dt.NewRow();
string[] rowString = new string[10];
rowString=line.Split(" ")


I hope it helpful to you.