ralphtrent
Programmer
I have been looking for away to retrieve all the data in a data column with out a manual loop. this is what I have come up with.
OUTPUT
Code:
DataTable ldtDataTable = new DataTable("Data");
ldtDataTable.Columns.Add("Column1", typeof(String));
ldtDataTable.Columns.Add("Column2", typeof(String));
ldtDataTable.Columns.Add("Column3", typeof(String));
ldtDataTable.Rows.Add(new object[] { "Row1Column1", "Row1Column2", "Row1Column2" });
ldtDataTable.Rows.Add(new object[] { "Row2Column1", "Row2Column2", "Row2Column2" });
ldtDataTable.Rows.Add(new object[] { "Row3Column1", "Row3Column2", "Row3Column2" });
ldtDataTable.Rows.Add(new object[] { "Row4Column1", "Row4Column2", "Row4Column2" });
ldtDataTable.Rows.Add(new object[] { "Row5Column1", "Row5Column2", "Row5Column2" });
var t = (from value in ldtDataTable.AsEnumerable() select value.Field<string>("Column2"));
Array tArray = t.ToArray();
string lstrValues = string.Empty;
Array.ForEach((String[])tArray, z => lstrValues += z + "; ");
OUTPUT
Code:
[green]
Row1Column2; Row2Column2; Row3Column2; Row4Column2; Row5Column2;
[/green]