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

Getting row column data into the grid after original databinding operation

2 Answers 66 Views
GridView
This is a migrated thread and some comments may be shown as answers.
SUNIL
Top achievements
Rank 2
Iron
SUNIL asked on 26 Dec 2010, 10:12 PM
The data-binding of a grid is done  and then at a later point of time some of the missing values in original data become known.
How would I refresh the grid so the missing values show up in the grid? One way seems to be to re-bind the grid, but I think there might be a better approach.
As an example, a grid has a datasource of List<MyCar>.  But, when the original databinding is done,the car price and car depreciation are missing for each MyCar row.. These missing values are available later on, much after the original data-binding operation. The class MyCar is as listed below.
I am using Q1 2008 SP1 version of Winforms RadControls.

Thanks
Sunil

public class MyCar
    {
        private string _carOwner;
        private string _carModel;
        private int _carYear;
        private string _carColor;
        private double _carPrice;
        private double _carDepreciation;
 
        public MyCar(string carOwner, string carModel, int carYear, string carColor, double carPrice, double carDepreciation)
        {
            CarOwner = carOwner;
            CarModel = carModel;
            CarYear = carYear;
            CarColor = carColor;
            CarPrice = carPrice;
            CarDepreciation = carDepreciation;
        }
        public string CarOwner
        {
            get { return _carOwner; }
            set { _carOwner = value; }
        }
        public string CarModel
        {
            get { return _carModel; }
            set { _carModel = value; }
        }
        public int CarYear
        {
            get { return _carYear; }
            set { _carYear = value; }
        }
        public string CarColor
        {
            get { return _carColor; }
            set { _carColor = value; }
        }
        public double CarPrice
        {
            get { return _carPrice; }
            set { _carPrice = value; }
        }
        public double CarDepreciation
        {
            get { return _carDepreciation; }
            set { _carDepreciation = value; }
        }
 
 
    }

2 Answers, 1 is accepted

Sort by
0
SUNIL
Top achievements
Rank 2
Iron
answered on 27 Dec 2010, 02:25 AM
I think an option would be to implement  'INotifyPropertyChanged' interface for the MyCar class.
0
Accepted
Stefan
Telerik team
answered on 29 Dec 2010, 10:20 AM
Hello Sunil,

Thank you for writing.

As you already said, you should implement INotifyPropertyChanged interface for your business objects. In addition you have to use BindingList instead of List, or you have to implement the IBindingList interface. Once these requirements are met, RadGridView will be notified when there are changes applied and it will update its UI automatically.

I hope this information addresses your question. If you have any further questions, do not hesitate to ask.

Best wishes,
Stefan
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Tags
GridView
Asked by
SUNIL
Top achievements
Rank 2
Iron
Answers by
SUNIL
Top achievements
Rank 2
Iron
Stefan
Telerik team
Share this question
or