public void PrintTable(DataTable table) { for (int j = 0; j < table.Columns.Count; j++) Console.Write("{0,-20}", table.Columns[j].ColumnName); Console.WriteLine(); for (int i = 0; i < table.Rows.Count; i++) { for (int j = 0; j < table.Columns.Count; j++) { Console.Write("{0,-20}",table.Rows[i][j]); } Console.WriteLine(); } } private void PrintView(DataView view) { for (int j = 0; j < view.Table.Columns.Count; j++) Console.Write("{0,-15}", view.Table.Columns[j].ColumnName); Console.WriteLine(); //loop thru the dataview for (int i = 0; i < view.Table.Rows.Count; i++) { for (int j = 0; j < view.Table.Columns.Count; j++) { Console.Write("{0,-15}", view[i][j]); } Console.WriteLine(); } }
Wednesday, October 15, 2008
How to print DataTable and DataView
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment