Click here to Skip to main content
15,921,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to use gridview control in my windows application and connect it with any text file, XML file and excel file.The data source should be text file, XML and excel file.what is the method to connect gridview with text file and excel file and XML file??

Thanks
Posted

Link to bind to xml file - here.

Link to bind to text file - here.
You could just read your text file into an Arraylist and bind it to your gridview.

Link to bind to excel - here.
 
Share this answer
 
1- You can’t directely bind a text file to a grid, you need to read that file into a collection and bind the collection the grid.

2- Read the xml file into a dataset ds.ReadXml(filePath) and bind it to the grid

Or use XMLDocumentData

XMLDocumentData doc = new XMLDocumentData();
xmlDoc.ReadXML(filename);
DataGridView.DataSource = doc.Dataset;


3- For excel you can use JET oledb provider to access the worksheet

You can read more here

http://social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/ce4bbe9c-7d13-44c5-a26c-4b84912a51f3/[^]
 
Share this answer
 

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