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

Refresh RadGrid

4 Answers 758 Views
GridView
This is a migrated thread and some comments may be shown as answers.
pierre-jean
Top achievements
Rank 1
Veteran
Iron
pierre-jean asked on 21 Nov 2016, 10:55 PM

I use the following function to load Horse names starting with a given letter

The first call returns and displays the list in the grid view

But at the second and following calls, while the HorseList is correctly generated, the display in the grid does not display the new list

I know that this questionhas been discussed many times but I have not found the solution .....

Thanks in advance

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

      Public Function LoadNode(ByVal FirstLetter As String) As Boolean
        Try
            Dim aHorse As New mHorse
            Dim Horses As New List(Of Horse)
            'Load the Horses list where the name starts with "FirstLetter"
            Horses = aHorse.LoadNode(FirstLetter)
            If Horses.Count > 0 Then
                gvHorse.BeginUpdate()
                gvHorse.DataSource = Horses
                gvHorse.EndUpdate()
            Else

            End If
        Catch ex As Exception

        End Try
    End Function

4 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Nov 2016, 12:11 PM
Hello Pierre-Jean,

Thank you for writing.  

RadGridView is capable of fetching bindable properties and data. However, one important issue must be noted: during the data binding process, the grid extracts the data from the data source, but for any later changes in the data source, RadGridView should be notified. Your bindable collection and business objects should follow some standards established in .NET in order to notify RadGridView about the changes. The following help article is quite useful on this topic: http://docs.telerik.com/devtools/winforms/gridview/populating-with-data/reflecting-custom-object-changes-in-rgv

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
0
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 22 Nov 2016, 02:35 PM

Hello Dess

Thanks for your reply that gives me the direction of the solution.

I have spent a considerable amount of time reading and trying but I have not been able to implement the solution, i.e. how to generate a bindable list

I understand that my question is not strictly speaking a "telerik issue", however if you coud tell me how to modifiy the below code to generate a bindable object from my entityframework context I would be extremely gratefull (or if you have a simple example)

--------------------------------------------------------------------------------------------------------

HorseListe as list(of Horse) =  (From aHorse As Horse In context.Horses Where aHorse.CurrentName.StartsWith(FirstLetter)  Order By aHorse.CurrentName).ToList()

-------------------------------------------------------------------------------------------------------

Thanks a lot

 

0
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 23 Nov 2016, 04:31 PM

OK this solved the problem:

 

    Public Function GetHorses(startChar As String) As BindingList(Of Horse)
        Dim context As New WJSQLEntities
        Dim query = (From aHorse As Horse In context.Horses Where aHorse.CurrentName.StartsWith(startChar) Order By aHorse.CurrentName)
        Return New BindingList(Of Horse)(query.ToList)
    End Function

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Nov 2016, 08:56 AM
Hello Pierre-Jean, 

Thank you for writing back. 

I am glad that the problem you were facing is now resolved. The following help article demonstrates how to bind RadGridView to EntityFramework: http://docs.telerik.com/devtools/winforms/gridview/populating-with-data/binding-to-entityframework-using-database-first-approach

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Telerik by Progress
Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
Tags
GridView
Asked by
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Share this question
or