Solved

Help with saving data added in DatagridView

Posted on 2016-10-02
1
61 Views
Last Modified: 2016-10-03
Hello,

How do I modify the code below to save new records entered in a DataGridView?, I'm able to save changes made to existing rows but can not save data entered in new rows.

 Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
        Dim GGB As String
        GGB = "'" & ComboBox1.SelectedItem & "'"
        Dim SearchCriteriaZ As String = "COUNTRY IN (" & GGB & ")"
        xmlPath1 = System.IO.Path.Combine(Application.StartupPath + "\file1.xml")  'grid1
        dtsetcol1.Clear()
        dtsetcol1.ReadXml(xmlPath1)

        Dim DVA As New DataView(dtsetcol1.Tables(0), SearchCriteriaZ, Nothing, DataViewRowState.CurrentRows)
        FilteredDTA = DVA.ToTable
End Sub

 Private Sub Save_Click(sender As System.Object, e As System.EventArgs) Handles Save.Click

          FilteredDTA.WriteXml(Application.StartupPath + "\file1.xml")
        MsgBox("Records saved")
    End Sub

Thanks,

Victor
0
Comment
Question by:vcharles
1 Comment
 
LVL 29

Accepted Solution

by:
Randy Downs earned 500 total points
ID: 41826393
Try something like this

  

    ' Add one row:
    dataRow = dataTable.NewRow()
    dataRow("dataColumn") = "World"
    dataTable.Rows.Add(dataRow)

    ' Set the RowStateFilter to display only Added and modified rows.
    dataView.RowStateFilter = _
    DataViewRowState.Added Or DataViewRowState.ModifiedCurrent

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question