This is a migrated thread and some comments may be shown as answers.

Unable to refesh grid rows to reflect changes to column values in database

1 Answer 62 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kevin Weir
Top achievements
Rank 1
Kevin Weir asked on 16 Jul 2009, 08:44 PM

I use the following code to populate a GriveView control.  As you can see oBundleEntriesDAL.GetByBundleID returns an IQueryable object which is used to set GridView.DataSource.

 

 


 

Private Sub PopulateBundleEntries()

 

 

    Dim oBundleEntriesDAL As New BundleEntriesDAL(_ContextConnection)

 

    gvBundleEntries.MasterGridViewTemplate.AutoGenerateColumns =

False

 

 

 

 

    gvBundleEntries.DataSource = oBundleEntriesDAL.GetByBundleID(_BundleID)

 

End Sub

 

 

 

 

 

Public Function GetByBundleID(ByVal bundleID As Integer) As IQueryable(Of BundleEntry)

 

 

     Dim query = From bundleEntries In _Context.BundleEntries.Include("Bundle") _

 

 

                         Where bundleEntries.Bundle.BUNDLE_ID = bundleID _

 

 

                         Select bundleEntries

 

 

    Return query

 

 

End Function

 

 

I have a form that calls PopulateBundleEntries() when the form is loaded.   Later, if I add a row to the underlying database and call PopulateBundleEntries() again the row appears in the GridView control as it should.  However, if I change some column values for an existing row in the database and call PopulateBundleEntries() again the changes in the database are not reflected in the GridView.   I have tried clearing the rows before DataSource is set but that doesn't resolve the problem.   I tried using Rows.Clear and Rows.RemoveAt but neither of those options worked.

 

 

What am I doing wrong?  How do I get the GridView to display column values that have CHANGED in the underlying database?

Steps to Reproduce Problem

1) Populate GridView in Forms Load Event  (call PopulateBundleEntries())
2) Add a row to database and refresh the grid to reflect the change  (call PopulateBundleEntries())
3) Change column values for existing row in the database and refesh the grid to reflect the change   (call PopulateBundleEntries())

1 Answer, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 20 Jul 2009, 12:22 PM
Hello Kevin,

Thank you for writing. I am afraid that I can not tell exactly why this happens by looking at the code you provided. The fact that new rows are reflected in RadGridView means that the data source implements the IBindingList interface and notifies the grid properly.

Perhaps they do not get refreshed because the objects which represent the rows in your data source do not implement the INotifyPropertyChanged interface.

Please send a sample application with a data source so that I can tell you exactly what has to be done. I am looking forward to your reply.

Best wishes,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Kevin Weir
Top achievements
Rank 1
Answers by
Victor
Telerik team
Share this question
or