Displaying data of data table

I still can't post a comment but here is a quick answer:

 foreach(DataRow row in myTopTenData.Rows)
 { 
     string ID  = row["ColumnID"].ToString();
     string Name= row["columnName"].ToString();
     string FamilyName= row["ColumnFamilyName"].ToString();    
 }

Make sure to check for null values when retrieving the data


Assuming that myTopTenData is a DataTable then you loop on rows of a datatable in this way

foreach (DataRow row in myTopTenData.Rows)
{
     Console.WriteLine();
     for(int x = 0; x < myTopTenData.Columns.Count; x++)
     {
          Console.Write(row[x].ToString() + " ");
     }
}

Of course this snippet should be taken only as a trivial example.
You need to consider null values and a robust error checking.


You can use Datagrid to display your DataTable like this :

in WPF :

datagrid.SetBinding(ItemsControl.ItemsSourceProperty, new System.Windows.Data.Binding { Source = dt});

in winform :

datagrid.DataSource(datatable);