Hi,
Here I am giving some code snipet using stream reader to retrive some information from a .txt file and binding it to a grid view, after assigning those information to a datatable.
<pre lang="c#"> using (FileStream s = new FileStream("C:/TextFileToGridView.txt", FileMode.Open))
using (StreamReader r = new StreamReader(s))
{
List<Object> ds = new List();
while (!r.EndOfStream)
{
String l = r.ReadLine();
if (l[0] != '%')
{
String p = l.Replace(" ", ";");
String[] a = p.Split(';');
if (a[0] != "")
{
ds.Add(new { c0 = a[0], c1 = a[1], c2 = a[2], c3 = a[3] });
}
}
}
GridView1.DataSource = ds;
GridView1.DataBind();
}
If you want any clarification please revert.
Thanks
tapan kumar