If you want the total number of columns use:
DataTable.Columns.Count();
If you want the max value for a column you can use this:
DataTable myDataTable = new DataTable();
myDataTable.Columns.Add("amount");
myDataTable.Columns["amount"].DataType=typeof(decimal);
DataRow row1 = myDataTable.NewRow();
row1["amount"] = 5.0;
myDataTable.Rows.Add(row1);
DataRow row2 = myDataTable.NewRow();
row2["amount"] = 9.0;
myDataTable.Rows.Add(row2);
//int totalColumns = myDataTable.Columns.Count;
decimal maxamount = (Decimal)myDataTable.AsEnumerable().Max(row => row["amount"]);
"If there's nothing wrong with me, maybe there's something wrong with the universe!"
No comments:
Post a Comment