Solved

Changing value of bound datagridview cell

Posted on 2013-06-04
3
418 Views
Last Modified: 2013-06-13
Hello experts, I am trying to set a value in datagridview via code. the grid is bound to a bounding source.
apparently the data base wont update. this is my code:


Dim row As DataRow = DirectCast(Me.TblLaboratoryBindingSource1.Current, DataRowView).Row
                row("Nomicrosection") = lngNewSeedNoMicroSection
                row("TestDate") = DateTime.Now
                dtgLab.Item("Nomicrosection", i).Value = lngNewSeedNoMicroSection
                dtgLab.Item("TestDate", i).Value = DateTime.Now
dtDataTable.GetChanges()

       
            TblLaboratoryTableAdapter.Update(dtDataTable.Select(Nothing, Nothing, DataViewRowState.Deleted))
           
            TblLaboratoryTableAdapter.Update(dtDataTable.Select(Nothing, Nothing, DataViewRowState.ModifiedCurrent))
         
            TblLaboratoryTableAdapter.Update(dtDataTable.Select(Nothing, Nothing, DataViewRowState.Added))

            COCDataSet.tblLaboratory.AcceptChanges()
0
Comment
Question by:Hagita
  • 2
3 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 39220758
What is the underlying query?

Does it use multiple tables?
If so it may be that it is not updateable

mlmcc
0
 

Accepted Solution

by:
Hagita earned 0 total points
ID: 39232581
Thank you. I managed to make it work. added a call to the  EndEdit method opf the BindingSource:

           dtDataTable.GetChanges()
            Me.TblLaboratoryBindingSource1.EndEdit()
         
            TblLaboratoryTableAdapter.Update(dtDataTable.Select(Nothing, Nothing, DataViewRowState.Deleted))      
            TblLaboratoryTableAdapter.Update(dtDataTable.Select(Nothing, Nothing, DataViewRowState.ModifiedCurrent))          
            TblLaboratoryTableAdapter.Update(dtDataTable.Select(Nothing, Nothing, DataViewRowState.Added))

            COCDataSet.tblLaboratory.AcceptChanges()
0
 

Author Closing Comment

by:Hagita
ID: 39243888
I solved it without using experts advice. Thank you
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

825 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