开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜