I need to convert Ilist to datatable using below method.But couldnt.Please help .
Here when I select items from checkbox of ultracomboeditor - I need to add them to datatable.So
this.ultraComboEditor1.CheckedListSettings.CheckBoxStyle = CheckStyle.CheckBox;
System.Collections.IList values = null;
values = this.ultraComboEditor1.Value as System.Collections.IList;
my Problem is to convert the ILIst to datatable.
using below method I want to convert IList to datatable.Please show how.
public DataTable ToDataTables(IList data)
{
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(T));
DataTable table = new DataTable();
for (int i = 0; i < props.Count;i++ )
{
PropertyDescriptor prp = props[i];
table.Columns.Add(prp.Name,prp.PropertyType);
}
object[] values = new object[props.Count];
foreach(T item in data)
{
for (int i = 0; i < values.Length;i++ )
{
values[i] = props[i].GetValue(item);
}
table.Rows.Add(values);
}
return table;
}
Thanks in advance.

VulpesRank #55 · 29.2K reputationPosted Jul 3, 2013, 7:53 AM EDT
The output is:
I'm not familiar with the UltraComboEditor but I've been looking at the docs for it and, from what you say, it sounds like it's the CheckedItems property you want to convert to a DataTable.
Now the type of this property is CheckedValueListItemsCollectionand, as far as I can see, it doesn't implement either IList or its generic equivalent.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 3, 2013, 7:22 PM EDT
Please check following link it might help you.
http://stackoverflow.com/questions/564366/convert-generic-list-enumerable-to-datatable
http://www.dotnetperls.com/convert-list-datatable
Posted Jul 3, 2013, 7:35 PM EDT