[Solved] RadGridView Refresh

1 Answer 35 Views
GridView
Carl
Top achievements
Rank 1
Iron
Iron
Iron
Carl asked on 06 Feb 2026, 09:09 PM

I have what seems like a simple task.

My grid looks like this:

and I create it by pulling the data and passing it to the SetupGrid() method (partially) shown below which creates the columns and sets the DataSource.  This part works fine.

        private void SetupGrid(RadGridView grid,
                                List<Dictionary>? dictionaryList,
                                List<CreditInquirySetupEF>? efList,
                                List<CreditInquirySetupTU>? tuList)
        {
            grid.Columns.Clear();
            grid.Rows.Clear();
            grid.Templates.Clear();

            grid.MasterTemplate.AutoGenerateColumns = true;
            grid.MasterTemplate.ReadOnly = true;
            grid.MasterTemplate.ShowChildViewCaptions = false;
            grid.MasterTemplate.ShowRowHeaderColumn = false;

            grid.ShowRowHeaderColumn = false;
            grid.ShowChildViewCaptions = false;

            GridViewTemplate template1 = new GridViewTemplate();
            GridViewTemplate templateApp = new GridViewTemplate();

            if (efList is not null)
            {
                template1.AutoGenerateColumns = false;
                template1.DataSource = null;
                template1.DataSource = efList;
                template1.AllowAddNewRow = false;
                template1.ReadOnly = true;
                template1.ShowRowHeaderColumn = false;
                template1.Caption = string.Empty;

                grid.MasterTemplate.Templates.Add(template1);

                template1.MasterTemplate.ShowChildViewCaptions = false;

                GridViewRelation relation1 = new GridViewRelation(grid.MasterTemplate);
                relation1.ChildTemplate = template1;
                relation1.RelationName = "EQVendorID";
                relation1.ParentColumnNames.Add("DictionaryKey");
                relation1.ChildColumnNames.Add("VendorID");
                grid.Relations.Add(relation1);
            }

            if (tuList is not null)
            {
                templateApp.AutoGenerateColumns = false;
                templateApp.DataSource = null;
                templateApp.DataSource = tuList;
                templateApp.AllowAddNewRow = false;
                templateApp.ReadOnly = true;
                templateApp.ShowRowHeaderColumn = false;
                templateApp.ShowChildViewCaptions = false;
                grid.MasterTemplate.Templates.Add(templateApp);

                GridViewRelation relationApp = new GridViewRelation(grid.MasterTemplate);
                relationApp.ChildTemplate = templateApp;
                relationApp.RelationName = "TUVendorID";
                relationApp.ParentColumnNames.Add("DictionaryKey");
                relationApp.ChildColumnNames.Add("VendorID");
                grid.Relations.Add(relationApp);
            }

            grid.DataSource = null;
            grid.DataSource = dictionaryList;

            grid.MasterTemplate.Columns["BranchID"].IsVisible = false;
            grid.MasterTemplate.Columns["DictionaryID"].IsVisible = false;
            grid.MasterTemplate.Columns["DictionaryKey"].IsVisible = false;
            grid.MasterTemplate.Columns["DictionaryKeyString"].IsVisible = false;
            grid.MasterTemplate.Columns["DictionaryTypeID"].IsVisible = false;
            grid.MasterTemplate.Columns["Active"].IsVisible = false;

            grid.MasterTemplate.Columns["Description"].Width = 300;
            grid.MasterTemplate.Columns["Description"].HeaderText = "Bureau Name";
            grid.MasterTemplate.Columns["Description"].HeaderTextAlignment = ContentAlignment.MiddleLeft;

            var buttonCol = new GridViewImageColumn();

            buttonCol = new GridViewImageColumn();
            buttonCol.HeaderText = "";
            buttonCol.Name = "Propertys";
            buttonCol.HeaderImage = VisionUI.Properties.Resources.Plus_13;
            buttonCol.Width = 30;
            buttonCol.AllowSort = false;

            grid.MasterTemplate.Columns.Add(buttonCol);


            if (efList is not null)
            {
                grid.MasterTemplate.Templates[0].Caption = "";

                var column = new GridViewTextBoxColumn();

                column.FieldName = "VendorID";
                column.Name = "VendorID";
                column.IsVisible = false;
                grid.MasterTemplate.Templates[0].Columns.Add(column);


                column = new GridViewTextBoxColumn();

                column.FieldName = "SettingsBranchID";
                column.Name = "SettingsBranchID";
                column.IsVisible = false;
                grid.MasterTemplate.Templates[0].Columns.Add(column);


                column = new GridViewTextBoxColumn();

                column.FieldName = "ServiceName";
                column.Name = "ServiceName";
                column.Width = 145;
                column.HeaderText = "Service Name";
                column.HeaderTextAlignment = ContentAlignment.MiddleLeft;
                column.TextAlignment = ContentAlignment.MiddleLeft;
                column.IsVisible = true;
                grid.MasterTemplate.Templates[0].Columns.Add(column);

The problem comes when I delete a row in the subgrid and physically removing it from the db table. I tried removing the deleted entry from the collection and refreshing and even pulling the data from the database again like this:

               int settingsBranchID = absUIControls.GetGridValueInt(gvServiceNames, "SettingsBranchID");

               await creditInquirySetupEF.DeleteServiceNameAsync(settingsBranchID);
               await creditInquirySetupTU.DeleteServiceNameAsync(settingsBranchID);

               vendorList = CommonServices.GetDictionary(EDictionaryType.CreditInquiryVendor, creditInquirySetupEF.BranchID, false);

               creditInquirySetupEFList = await creditInquirySetupEF.GetCreditInquirySetupEFAsync(creditInquirySetupEF.BranchID);
               creditInquirySetupTUList = await creditInquirySetupTU.GetCreditInquirySetupTUAsync(creditInquirySetupTU.BranchID);

               gvServiceNames.DataSource = null;
               gvServiceNames.Templates[0].DataSource = null;
               gvServiceNames.Templates[1].DataSource = null;

               gvServiceNames.DataSource = vendorList;
               gvServiceNames.Templates[0].DataSource = creditInquirySetupEFList;
               gvServiceNames.Templates[1].DataSource = creditInquirySetupTUList;

               gvServiceNames.Refresh();
               gvServiceNames.Templates[0].Refresh();
               gvServiceNames.Templates[1].Refresh();


               foreach (var item in gvServiceNames.Rows)
               {
                   item.IsExpanded = true;
               }

               gvServiceNames.Templates[0].Rows[0].IsSelected = true;

When I reassign the datasources, for some reason the top grid formats like this:



Any ideas as to why?

Thanks

Carl

 


1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 11 Feb 2026, 05:56 PM

Hello, Carl,

Note, RadGridView is capable of fetching bindable properties and data. However, 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 collection that you will bind to RadGridView should implement IBindingList or IBindingListView interfaces. This will allow RadGridView to get notified about insert and delete operations of records.
- Your business objects should implement INotifyPropertyChanged interface. This will allow RadGridView to reflect changes that occur to the properties of the business objects.

I would recommend you to refer to the following articles: WinForms GridView Populating with Data Reflecting Custom Object Changes in RGV - Telerik UI for WinForms

According to the provided code snippet, it seems that you are using the List<T>, such as  List<Dictionary>, List<CreditInquirySetupEF>, etc. If you want RadGridView to be updated automatically, you can switch to BindingList<T>. BindingList<T> implements the IBindingList interface and provides the features required to support both complex and simple scenarios when binding to a data source. 

You can also check our example using BindingList as a datasource to RadGridView here: WinForms GridView Populating with Data Binding to BindingList - Telerik UI for WinForms

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

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GridView
Asked by
Carl
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or