Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to fetch data from text file with two tables and show in the different datagridview using C#.net?

my text file name is test.txt

table1

A B ----- column name

1 1

3 7

5 3



table2

A B ----- column name

3 6

7 4

5 7



now i have two datagridview dgvTab1 and dgvTab2 now i want to populate those test text value in these datagridview with column name(A B). and add delete update operation using C#. plz if u have any solution, give me.

thanks in advance
Posted

1 solution

We can't answer that: a text file doesn't have tables, rows or columns - it barely has lines (and those are just a basic interpretation of the content for a particular system.

So we can't tell you how to read two tables of data from a text file because we have no idea how the data is organised and whet indicates that "this is a row" and "this is the start of a new table", much less what says "This is a column" and "this is the next column". You need to sit down, look at your data and work all of that out. But which time, of course, you will have 90% of the file processing algorithm sorted out yourself and ready for coding...:laugh:

Displaying in two DataGridViews it trivial: load each table from your file into a separate DataTable, and set it as the DataGridView.DataSource parameter - the system will take care of it for you.
 
Share this answer
 
Comments
yogesh rajoriya 21-May-14 13:49pm    
if you other way to solve this problem plz share with me..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900