score:10

Accepted answer

The problem is that you didn't specify that your columns are ints. You can specify that with the Add(string, Type) method.

dt.Columns.Add("RowId", typeof(int));
dt.Columns.Add("Amount", typeof(int));

DataRow row = dt.NewRow();
// whether you add strings or ints here doesn't matter, it's converted
row[0] = "1";
row[1] = 2000;

Related Articles