I have one dictionary Like
Dictionary<string, List<string>> first=new Dictionary<string, List<string>>();
I want to bind this dictionary to data table such that data table ColumnName should be key of the dictionary and respective columns should contain their dictionary values. What I tried:
Dictionary<string, List<string>> some= new Dictionary<string, List<string>>();
System.Data.DataTable dt = new System.Data.DataTable();
foreach (var entry in some)
{
if (entry.Value.Count > 0)
{
dt.Columns.Add(entry.Key);
//entry.Value.count is not same for all entry.Key
foreach (var value in entry.Value)
{
DataRow row = dt.NewRow();
row[entry.Key] = value;
dt.Rows.Add(row);
}
}
}
Surely I know, above code is having some errors to achieve following result DesirrdResultImage any suggestions?