"Philip Townsend" <pt*******@v1te ch.com> wrote in message
news:Ok******** *****@tk2msftng p13.phx.gbl...
Is there any way to manually add a record to a dataset? In my case, I
may need to populate the dataset from a stored procedure or xml file,
but in some cases I may need to manually add an additional record or
row. Any suggestions? Thanks!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
This is code that is used in one of the data templates in Web Matrix,
in order to add an empty row to a datagrid (for inserting a new record)
Dim myCommand As New OleDBDataAdapte r(SelectCommand ,
myConnection)
Dim ds As New DataSet()
myCommand.Fill( ds)
' add a new blank row to the end of the data
Dim rowValues As Object() = {0, "", "","","","" }
ds.Tables(0).Ro ws.Add(rowValue s)
' figure out the EditItemIndex, last record on last page
Dim recordCount As Integer = ds.Tables(0).Ro ws.Count
If recordCount > 1 Then
recordCount -= 1
DataGrid1.Curre ntPageIndex = recordCount \
DataGrid1.PageS ize
DataGrid1.EditI temIndex = recordCount Mod DataGrid1.PageS ize
End If
' databind
DataGrid1.DataS ource = ds
DataGrid1.DataB ind()
--
Jos Branders