Adding rows to a dataSet
-
Hello, I am attempting to add rows to a dataSet using the InsertAt method. After adding a row, when I iterate through the dataSet to display the data, the new row does not appear. Also, the Rows.count does not increase. The strange thing is, if I bind the dataSet to a dataGrid, the new row does appear at the bottom, so the row is definitely being added. Does anybody know what's going on? Thanks, RC
-
Hello, I am attempting to add rows to a dataSet using the InsertAt method. After adding a row, when I iterate through the dataSet to display the data, the new row does not appear. Also, the Rows.count does not increase. The strange thing is, if I bind the dataSet to a dataGrid, the new row does appear at the bottom, so the row is definitely being added. Does anybody know what's going on? Thanks, RC
You have to create a new DataRow object first, then populate it with the values befor adding it to the dataSet:
c# Datarow dr = MyDataSet.tables[0].NewRow(); dr[0] = 'value'; dr[1] = 'value'; MyDataSet.tables[0].Rows.Add(dr);
(I think I have the code correct, no ide here). If you are a vb'er Im sure you'll work it out from this. Hope it helps Rob