Adding array of string to a datacolumn of a data table
How can I add an array of string to data column of a a开发者_StackOverflown empty data table in asp.net?
You're not providing a whole lot of info on what you actual need (e.g. structure of table) but here's a way to get started:
string[] values = new string[10];
DataTable table = new DataTable();
table.Columns.Add("Column 1", Type.GetType("System.String"));
foreach (string value in values)
{
DataRow row = table.NewRow();
row["Column 1"] = value;
table.Rows.Add(row);
}
精彩评论