0

How can I add an array of string to data column of a an empty data table in asp.net?

1 Answer 1

2

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);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.