Hi,
i've try to bind WebGrid to my ObservableCollection. I set the DataSource property and later I call DataBind(). Furthermore I define a BoundField and add it to the WebGrid Columns.<ObservableCollection<myClass> myOberservableCollection;<this.WebGrid.DataSource= myOberservableCollection;<BoundFiled bf = new BoundField(); <bf.HeaderText = "Key";<bf.DataField="Key";<this.WebGrid.Columns.Add(bf);<this.WebGrid.DataBind();
In my class which represent the items in my ObservableCollection I implement INotifyPropertyChanged Interface and the PropertyChangedEventHandler.In all properties of this class I raise this event.<public class myClass : INotifyPropertyChanged
<public event PropertyChangedEventHandler PropertyChanged;<public void myPropertyChanged(string propertyname)< { If (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyname));<public int Key< { get { return _key; } set { _key = value; myPropertyChanged("Key"); }
But the properties are never been raised! I guess something is missing!?With similar behavoir on my WPF or Silverlight project it works fine with Infragistics Grid.
thx in advance
frank
thx I fill out the request form
Hello,
Yes, I have discussed that with the ASP.NET team and this (support for ObservableCollection and INotifyPropertyChanged) is something that we will be investigating and potentially implement in subsequent releases. I think it is also a very good idea if you suggest this formally to our PMs via the following form
Request a Feature or Component
PM goes through customer requestss regularly and actually from my experience much of our TODO list and roadmap is based on customer requests.
HTH,
proper that sounds good to me. I guess obeservable collection have considerable advantages whiche are usefull to have in asp.net as well.thx for help. I hope you'll find a good and fast solution.
Now that I think about it, you probably do have a point and this needs proper investigation -- if this is something that we do not support and it makes sense, maybe we need to start supporting it. I will now investigate this in details (e.g. how stock controls like asp:GridView bind against ObservableCollection, how our grids do, how we cam improve) and will post a follow-up to this thread with what I find.
As far as two-way databinding goes, the easiest way I have found is by using the built-in ASP.NET declarative datasources, e.g. asp:AccessDataSource for Access database (mdb files), asp:SqlDataSource for Sql Server and Sql Server Express (.dmb files) and / or LinqDataSource when / if needed. All of them have design time interfaces and you can autogenerate CRUD commands (SELECT, UPDATE, CREATE, DELETE) and this syncs the grid with the datasource (two-way databinding)
In my point of view If I use ado.net data services and later cast my table in an observable collection I've got a disconnected construct in silverlight applications also.however, if we can't use observablecollection what do you think is the easiest way to sync mydata and the datasource of the WebGrid?