Monday, August 29, 2005

Converting Class Array to DataTable

//Variable Declarations
private DataTable dtTemp;

private static void FillData(PropertyInfo[] properties, DataTable dt, Object o)
DataRow dr = dt.NewRow();
foreach(PropertyInfo pi in properties)
dr[pi.Name] = pi.GetValue(o, null);

//All the Properties for the class array are converted to columns. We can always add a
//condition to include required columns alone.
private static DataTable CreateDataTable(PropertyInfo[] properties)
DataTable dt = new DataTable();
DataColumn dc = null;
foreach(PropertyInfo pi in properties)
dc = new DataColumn();
dc.ColumnName = pi.Name;
dc.DataType = pi.PropertyType;

return dt;

public static DataTable ConvertToDataTable(Object[] array)
PropertyInfo[] properties = array.GetType().GetElementType().GetProperties();
DataTable dt = CreateDataTable(properties);
if (array.Length != 0)
foreach(object o in array)
FillData(properties, dt, o);
return dt;

//Call like this
//Convert the Class Object Array to DataTable
dtTemp = ConvertToDataTable(clsData);

Valuable method for convert object array into datatable.Previously i used little bit complex method.Thanx a lot.
rgs chandima
Really Wonderful code. Helped me a lot
Thanks Kannan for taking the time to figure this out and post it online.
Es ist schade, dass ich mich jetzt nicht aussprechen kann - ist erzwungen, wegzugehen. Aber ich werde befreit werden - unbedingt werde ich schreiben dass ich denke. viagra kaufen cialis rezeptfrei [url=http//]levitra bestellen[/url]
Wow, nice post,there are many person searching about that now they will find enough resources by your post.Thank you for sharing to us.Please one more post about that..
That is very good comment you shared.Thank you so much that for you shared those things with us.Im wishing you to carry on with ur achivments.All the best. - [url=]site[/url] site
houston dating service list of radioactive dating techniques
free ebook dictionary download download power of full engagement ebook [url=]ebook shannon butcher[/url] melissa de la cruz ebook
ebook heliodorus ethiopian private placement memo ebook shareware trial [url=]certified protection professional ebook[/url] ebook dictionary free download
simetrix catena software adobe firefly software [url=]serona dental software[/url] computer midi sequencer software
[url=]UltraEdit 32 Professional 13.2 - Software Store[/url] parameter diagram and software
overdubbing recording software origin mapping software [url=]swing chords software[/url] outsourcing software solution india
[url=]Software di server - Software Store[/url] grant proposal writing software
gps software voice yadda yadda yadda software [url=]simply accounting training software[/url] parental monitoring software free trial version
[url=]Contactez-nous - Cheap Legal OEM Software, Software Sale, Download OEM[/url] best data recovery software and utilites
chattanooga pharmacy technician internet pharmacy bulletin boiards [url=]pharmacy phone[/url]
katwijk pharmacy inhouse pharmacy sumatriptan imigran imitrex tablets [url=]tretinoin cream 0 05 [/url]
pennsylvania pharmacy leglisltion document control procedurein community pharmacy [url=]cals pharmacy snowbords[/url]
pharmacy degree online pharmacy requirements [url=]diamox[/url]
cvs pharmacy chester nj pharmacy technician training online [url=]what exam to take for pharmacy technician[/url]
caremark specialty pharmacy ma jefferson pharmacy philadelphia [url=]arava[/url]
advanced compounding pharmacy inventory management pharmacy [url=]denmark pharmacy history[/url]
pharmacy concerns myriad pharmacy [url=]glucophage[/url]
does pa regulate internet pharmacy walmart pharmacy in erie pa [url=]document control procedurein community pharmacy[/url]
maine pharmacy law pseudoephedrine wegmans pharmacy fairport ny [url=]proscar[/url]
surgical supplies pharmacy eighth avenue new york pharmacy continue education [url=]how to become certified for pharmacy tech[/url]
lipitor online pharmacy south dakota state university pharmacy visit [url=]gift kamagra jelly[/url]
dating blueridge guitar [url=]romantic call[/url] glass door knob dating
liberal dating jopline dating
thinkers and feelers dating [url=]cougar women dating[/url] d s dating sites
dating websites for sale american girls for dating
torrent double your dating [url=]forensic science carbon dating autopsy[/url] porn tube wives dating
adult dating swinging oregon [url=]sex dating in romeoville illinois[/url] totally free no payment dating sight [url=]Akron[/url] dating sims new websites
Nice Post Love Reading Its

generic Viagra 100mg

kamagra 100mg
Post a Comment

This page is powered by Blogger. Isn't yours?