开发者

Adding array of string to a datacolumn of a data table

开发者 https://www.devze.com 2023-02-13 15:28 出处:网络
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

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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消