Click here to Skip to main content
15,897,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi How can I Create a List and Bind it to a DataTable?
In the first I must create a list

List<datatable> My_list = new List<datatable>();
1- How a list (by table format) could be created?


Then contains of DataTable must be bind to this list.

My_list = Bind_DataTable_to_List_function()
2- How can I create this function?

Thanks very much
Posted
Comments
Er Daljeet Singh 19-Nov-13 5:14am    
create a class which is having properties same as that columns you have in datatable.
then create a generic list of MyClass type.
then iterate the datatable.rows property which will return you row one by one ,fetch the value from row and add it to the property of myclass
then add add that object to the list.

You don't bind anything to a DataTable. Instead, you bind List and DataTable objects to displayable controls, such as DataGridView, or ListView.
 
Share this answer
 
If you are asking about converting Datatable into List, following article will be helpful.

http://codenicely.blogspot.in/2012/02/converting-your-datatable-into-list.html[^]
 
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