| | |
Convert List of Class objects to Datatable
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
Hi Guys,
I am in situation.. where I need to Convert List of Class objects to DataTable.
for example :
- Class Product
- ProductId,ProductName,Description,Price are the Product class's get/set properties.
- I got List<Products> - this need to DataTable
any help would be great...
Thank you
I am in situation.. where I need to Convert List of Class objects to DataTable.
for example :
- Class Product
- ProductId,ProductName,Description,Price are the Product class's get/set properties.
- I got List<Products> - this need to DataTable
any help would be great...
Thank you
Njoy koding... >>>
•
•
Join Date: Feb 2009
Posts: 38
Reputation:
Solved Threads: 0
I think there is an easier way, but I cant figure it out right now. This could help you accomplish your goal.
http://www.codeproject.com/KB/cs/coreweb01.aspx
http://www.codeproject.com/KB/cs/coreweb01.aspx
Thank You,
I got something like this
http://amitpatriwala.wordpress.com/2...-to-datatable/
I particularly wanted as..
where fnAllGetProducts() returns the List<Products> objects
I got something like this
http://amitpatriwala.wordpress.com/2...-to-datatable/
I particularly wanted as..
•
•
•
•
fnAllGetProducts().ToDatatable()
Njoy koding... >>>
•
•
Join Date: Nov 2006
Posts: 436
Reputation:
Solved Threads: 72
Looked at some of the links in this thread, and am surprised on how complicated some of these examples tend to be.
I use serialization and deserialization with a Binaryformater to store and retrieve class instances between an SQL database and a Windows form.
If you need more information on the subject, I can refer you to a wonderful book that explains it in detail, or I can supply you with a code snippet to get you started with this technique.
// Jerry
I use serialization and deserialization with a Binaryformater to store and retrieve class instances between an SQL database and a Windows form.
If you need more information on the subject, I can refer you to a wonderful book that explains it in detail, or I can supply you with a code snippet to get you started with this technique.
// Jerry
•
•
Join Date: Nov 2006
Posts: 436
Reputation:
Solved Threads: 72
http://www.amazon.com/Programming-NE...0018238&sr=1-1
The O'Reilly book by Juval Lowy named Programming .NET Components is a good resource.
The Serialization of a class to a byte array that can then be placed into a database record, then deserialized back again into your application at a later time is simple.
I use this technique a lot, as I have a Plugin framework that loads many DLLs as modules, forms, etc. One of the places where streaming the class comes in handy is capturing the Icon, a bunch of properties like the menu item the plugin will be loaded under, security settings and the like. The data is read in from the database, and the menus and buttons arranged according to the classes that are deserialized.
Another example is a painting program that has many layers. Rather than storing each layer in a sub-table, I just serialize the entire class collection of component properties, and place that in the database as a single record. When the user wants to see this artwork, I pull it from the database, and deserialize it, dynamically create all of the objects in the correct Z order, and render the artwork to the user (extremely fast and efficient).
// Jerry
The O'Reilly book by Juval Lowy named Programming .NET Components is a good resource.
The Serialization of a class to a byte array that can then be placed into a database record, then deserialized back again into your application at a later time is simple.
I use this technique a lot, as I have a Plugin framework that loads many DLLs as modules, forms, etc. One of the places where streaming the class comes in handy is capturing the Icon, a bunch of properties like the menu item the plugin will be loaded under, security settings and the like. The data is read in from the database, and the menus and buttons arranged according to the classes that are deserialized.
Another example is a painting program that has many layers. Rather than storing each layer in a sub-table, I just serialize the entire class collection of component properties, and place that in the database as a single record. When the user wants to see this artwork, I pull it from the database, and deserialize it, dynamically create all of the objects in the correct Z order, and render the artwork to the user (extremely fast and efficient).
// Jerry
![]() |
Other Threads in the C# Forum
- Previous Thread: ASP.NET Authentication issue
- Next Thread: Kuskal and Dijkstra
| Thread Tools | Search this Thread |
.net access ado.net algorithm array asp.net barchart bitmap box broadcast buttons c# check checkbox client color combo combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees developer development draganddrop drawing encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mandelbrot math mouseclick mysql nargalax operator path photoshop picturebox pixelinversion post programming radians regex remote remoting restore richtextbox save saving serialization server sleep socket sql stack statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





