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

GridView and linq to sql objects updating

1 Answer 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jorge Alberto
Top achievements
Rank 1
Jorge Alberto asked on 10 Sep 2010, 07:16 PM
Hello :)

Linq to Sql automatically generates classes that represents the relational tables of sql server as Objects in C#.
This Linq to Sql classes implements the INotifyPropertyChanging and INotifyPropertyChanged like this:
[Table(Name="dbo.hotel")]
    public partial class hotel : INotifyPropertyChanging, INotifyPropertyChanged
    {
         
        private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
         
        private int _idHotel;
         
        private int _ProveedorEmpresa_idProveedorEmpresa;
         
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnidHotelChanging(int value);
    partial void OnidHotelChanged();
    partial void OnProveedorEmpresa_idProveedorEmpresaChanging(int value);
    partial void OnProveedorEmpresa_idProveedorEmpresaChanged();
    #endregion
         
        public hotel()
        {
            OnCreated();
        }
         
        [Column(Storage="_idHotel", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
        public int idHotel
        {
            get
            {
                return this._idHotel;
            }
            set
            {
                if ((this._idHotel != value))
                {
                    this.OnidHotelChanging(value);
                    this.SendPropertyChanging();
                    this._idHotel = value;
                    this.SendPropertyChanged("idHotel");
                    this.OnidHotelChanged();
                }
            }
        }
         
        [Column(Storage="_ProveedorEmpresa_idProveedorEmpresa", DbType="Int NOT NULL")]
        public int ProveedorEmpresa_idProveedorEmpresa
        {
            get
            {
                return this._ProveedorEmpresa_idProveedorEmpresa;
            }
            set
            {
                if ((this._ProveedorEmpresa_idProveedorEmpresa != value))
                {
                    this.OnProveedorEmpresa_idProveedorEmpresaChanging(value);
                    this.SendPropertyChanging();
                    this._ProveedorEmpresa_idProveedorEmpresa = value;
                    this.SendPropertyChanged("ProveedorEmpresa_idProveedorEmpresa");
                    this.OnProveedorEmpresa_idProveedorEmpresaChanged();
                }
            }
        }
         
        public event PropertyChangingEventHandler PropertyChanging;
         
        public event PropertyChangedEventHandler PropertyChanged;
         
        protected virtual void SendPropertyChanging()
        {
            if ((this.PropertyChanging != null))
            {
                this.PropertyChanging(this, emptyChangingEventArgs);
            }
        }
         
        protected virtual void SendPropertyChanged(String propertyName)
        {
            if ((this.PropertyChanged != null))
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

If I bind the ItemSource of a RadGridView to a ObservableCollection of this classes generated by Linq to Sql, is necessary to do anything else in order to the gridview automatically updates its rows data or add and remove rows by just updating the ObservableCollection? Because the gridview is not updating its data.

I hope you can help me.

Best regards, Jorge

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 13 Sep 2010, 07:20 AM
Hi,

 Not sure why you have such problems however you can check the application attached to this thread for more info. 

Regards,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Jorge Alberto
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or