I feel like I must not be doing something right here. I have a DataTable and it’s currently able to take my arguments using the DataTable.Rows.Add method, but when I use DataTable.Rows.InsertAt it throws an error
What I’m currently doing with no issues:
dt.Rows.Add(new object[] { txtCompID.Text, scan(TrimStart('0'), txtEtaNum.Text, txtBinLocation.Text });
What I want to do (so the insert happens at the top), which is throwing “Argument 1: Cannot convert from ‘object[]’ to ‘System.Data.DataRow'”
dt.Rows.InsertAt(new object[] { txtCompID.Text, scan.TrimStart('0'), txtEtaNum.Text, txtBinLocation.Text }, 0);
You need to add row in dt that is of type of dt. You can use
dt.NewRow()method to get therow for dt. You can do it this way.