Solved

Changing value of bound datagridview cell

Posted on 2013-06-04
3
421 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 101

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

688 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