if you want to add list item to a datatable
dt.Columns.Add(name[0].ToString ());//here name is string type list
try like this
public DataTable GetResultsTable()
{
DataTable dt = new DataTable();
for (int i = 0; i < this.items.Count; i++)
{
string name = this.heading[i];
dt.Columns.Add(name);
List<object> objectNumbers = new List<object>();
foreach (double number in this.items[i])
{
objectNumbers.Add((object)number);
}
while (dt.Rows.Count < objectNumbers.Count)
{
dt.Rows.Add();
}
for (int a = 0; a < objectNumbers.Count; a++)
{
dt.Rows[a][i] = objectNumbers[a];
}
}
return dt;
}
GridView1 .DataSource = GetResultsTable();
GridView1.DataBind();
List<string> heading = new List<string>();
List<double[]> items = new List<double[]>();
heading.Add("Cat");
items.Add(new double[]
{
1.0,
2.2,
3.4
});
heading.Add("Dog");
items.Add(new double[]
{
3.3,
5.0,
7.0
});
</string></string>