We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Inserting row in datatable with InsertAt(), appends as last row in table

Say I have five rows in my DataTable (dtView) that has columns named "icon", "name" and "value". I want to get data from custom columns and rows of another DataTable (dtStyles) and insert it at row 3 in dtView, then I do like this: Dim dr As DataRow dr = dtView.NewRow dr(0) = System.String.Format("") dr(1) = dtStyles.Rows(RowNr).Item("displayname") dr(2) = dtStyles.Rows(RowNr).Item("value") dtView.Rows.InsertAt(dr, 3) -- This code results in an dtView DataTable where the new inserted row is appended as the last row, even thogh i have atleast 5 rows in my table and is inserting the new one at possition 3. What am I doing wrong?

1 Reply

AD Administrator Syncfusion Team October 25, 2002 04:43 AM UTC

After calling the InsertAt, try calling dtView.AcceptChanges() to see if that will place the row properly in your table.

Live Chat Icon For mobile
Up arrow icon