|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Working with Collections and DatagridsI have an application that is using Datagrids to display a collection of
objects (.Net 1.x, VB.Net environment using Collection Object). The Collection Object, lets say holds a collection of Customer Objects. I want the datagrid to be editable, so that users can enter data through the grid and have it update properties of the specific Customer object. Also I need for when the users clicks the new row in the datagrid that the Collection adds a new Customer object to it. The problem I am having is that when I click the new row in datagrid, I get a system.dll exception. What I see happening is that when new is clicked in the datagrid, the collection class returns a New Object(). Is there an event or property that I need to implement on my Customer Objects so that it will understand the datagrids request for a new object? Do a google search for
IEditableObject. http://www.google.com/search?hl=en&q=IEditableObject Its not trivial.... I usually go with a strongly typed dataset for this specific reason. (the work involved with implmenting IEditableObject) Show quote "Guy Thornton" <GuyThorn***@discussions.microsoft.com> wrote in message news:3659FE33-7008-41C5-B0CC-529232117D41@microsoft.com... > I have an application that is using Datagrids to display a collection of > objects (.Net 1.x, VB.Net environment using Collection Object). The > Collection Object, lets say holds a collection of Customer Objects. > I want the datagrid to be editable, so that users can enter data through the > grid and have it update properties of the specific Customer object. > > Also I need for when the users clicks the new row in the datagrid that the > Collection adds a new Customer object to it. The problem I am having is that > when I click the new row in datagrid, I get a system.dll exception. > > What I see happening is that when new is clicked in the datagrid, the > collection class returns a New Object(). Is there an event or property that > I need to implement on my Customer Objects so that it will understand the > datagrids request for a new object? I should have be more specific in my description, I have implemented my own
Collection class that implements IList, IBindingList, and ICollection interaces. I looked at the IEditableObject interace, but am not seeing how this will correct my problem. It seems that the IEditableObject interface is more responsible for managing changes to an object and either committing or discarding those changes when an edit begins or is cancelled. I will probably need to get to that task next, but for now, I just want return the correct type of object when a "new" is clicked by the user. Does the IEditableObject interface handle new object as well? Show quote "sloan" wrote: > Do a google search for > IEditableObject. > > http://www.google.com/search?hl=en&q=IEditableObject > > Its not trivial.... I usually go with a strongly typed dataset for this > specific reason. (the work involved with implmenting IEditableObject) > > > "Guy Thornton" <GuyThorn***@discussions.microsoft.com> wrote in message > news:3659FE33-7008-41C5-B0CC-529232117D41@microsoft.com... > > I have an application that is using Datagrids to display a collection of > > objects (.Net 1.x, VB.Net environment using Collection Object). The > > Collection Object, lets say holds a collection of Customer Objects. > > I want the datagrid to be editable, so that users can enter data through > the > > grid and have it update properties of the specific Customer object. > > > > Also I need for when the users clicks the new row in the datagrid that the > > Collection adds a new Customer object to it. The problem I am having is > that > > when I click the new row in datagrid, I get a system.dll exception. > > > > What I see happening is that when new is clicked in the datagrid, the > > collection class returns a New Object(). Is there an event or property > that > > I need to implement on my Customer Objects so that it will understand the > > datagrids request for a new object? > > > I ~think you need a default contructor.
And I think items in your Collection, have to implment the IEditable object. Buts its been over a year since I last did it, so I can't be authoratative with these answers. Show quote "Guy Thornton" <GuyThorn***@discussions.microsoft.com> wrote in message news:3CE948E1-77AA-4A01-BD16-790E59E947AF@microsoft.com... > I should have be more specific in my description, I have implemented my own > Collection class that implements IList, IBindingList, and ICollection > interaces. I looked at the IEditableObject interace, but am not seeing how > this will correct my problem. It seems that the IEditableObject interface is > more responsible for managing changes to an object and either committing or > discarding those changes when an edit begins or is cancelled. I will > probably need to get to that task next, but for now, I just want return the > correct type of object when a "new" is clicked by the user. Does the > IEditableObject interface handle new object as well? > > "sloan" wrote: > > > Do a google search for > > IEditableObject. > > > > http://www.google.com/search?hl=en&q=IEditableObject > > > > Its not trivial.... I usually go with a strongly typed dataset for this > > specific reason. (the work involved with implmenting IEditableObject) > > > > > > "Guy Thornton" <GuyThorn***@discussions.microsoft.com> wrote in message > > news:3659FE33-7008-41C5-B0CC-529232117D41@microsoft.com... > > > I have an application that is using Datagrids to display a collection of > > > objects (.Net 1.x, VB.Net environment using Collection Object). The > > > Collection Object, lets say holds a collection of Customer Objects. > > > I want the datagrid to be editable, so that users can enter data through > > the > > > grid and have it update properties of the specific Customer object. > > > > > > Also I need for when the users clicks the new row in the datagrid that the > > > Collection adds a new Customer object to it. The problem I am having is > > that > > > when I click the new row in datagrid, I get a system.dll exception. > > > > > > What I see happening is that when new is clicked in the datagrid, the > > > collection class returns a New Object(). Is there an event or property > > that > > > I need to implement on my Customer Objects so that it will understand the > > > datagrids request for a new object? > > > > > > Here's an example I found.
http://www.vb-helper.com/howto_net_sort_dataset_collection.html I don't know of a C# example offhand. ( I had that one in my old bookmarks) Show quote "sloan" <sl***@ipass.net> wrote in message news:%23h83U0DoGHA.3348@TK2MSFTNGP03.phx.gbl... > > I ~think you need a default contructor. > And I think items in your Collection, have to implment the IEditable object. > > Buts its been over a year since I last did it, so I can't be authoratative > with these answers. > > > > "Guy Thornton" <GuyThorn***@discussions.microsoft.com> wrote in message > news:3CE948E1-77AA-4A01-BD16-790E59E947AF@microsoft.com... > > I should have be more specific in my description, I have implemented my > own > > Collection class that implements IList, IBindingList, and ICollection > > interaces. I looked at the IEditableObject interace, but am not seeing > how > > this will correct my problem. It seems that the IEditableObject interface > is > > more responsible for managing changes to an object and either committing > or > > discarding those changes when an edit begins or is cancelled. I will > > probably need to get to that task next, but for now, I just want return > the > > correct type of object when a "new" is clicked by the user. Does the > > IEditableObject interface handle new object as well? > > > > "sloan" wrote: > > > > > Do a google search for > > > IEditableObject. > > > > > > http://www.google.com/search?hl=en&q=IEditableObject > > > > > > Its not trivial.... I usually go with a strongly typed dataset for this > > > specific reason. (the work involved with implmenting IEditableObject) > > > > > > > > > "Guy Thornton" <GuyThorn***@discussions.microsoft.com> wrote in message > > > news:3659FE33-7008-41C5-B0CC-529232117D41@microsoft.com... > > > > I have an application that is using Datagrids to display a collection > of > > > > objects (.Net 1.x, VB.Net environment using Collection Object). The > > > > Collection Object, lets say holds a collection of Customer Objects. > > > > I want the datagrid to be editable, so that users can enter data > through > > > the > > > > grid and have it update properties of the specific Customer object. > > > > > > > > Also I need for when the users clicks the new row in the datagrid that > the > > > > Collection adds a new Customer object to it. The problem I am having > is > > > that > > > > when I click the new row in datagrid, I get a system.dll exception. > > > > > > > > What I see happening is that when new is clicked in the datagrid, the > > > > collection class returns a New Object(). Is there an event or > property > > > that > > > > I need to implement on my Customer Objects so that it will understand > the > > > > datagrids request for a new object? > > > > > > > > > > > Thanks for the information. I will see what I can work out.
Show quote "sloan" wrote: > > Here's an example I found. > > http://www.vb-helper.com/howto_net_sort_dataset_collection.html > > I don't know of a C# example offhand. ( I had that one in my old bookmarks) > > > > "sloan" <sl***@ipass.net> wrote in message > news:%23h83U0DoGHA.3348@TK2MSFTNGP03.phx.gbl... > > > > I ~think you need a default contructor. > > And I think items in your Collection, have to implment the IEditable > object. > > > > Buts its been over a year since I last did it, so I can't be authoratative > > with these answers. > > > > > > > > "Guy Thornton" <GuyThorn***@discussions.microsoft.com> wrote in message > > news:3CE948E1-77AA-4A01-BD16-790E59E947AF@microsoft.com... > > > I should have be more specific in my description, I have implemented my > > own > > > Collection class that implements IList, IBindingList, and ICollection > > > interaces. I looked at the IEditableObject interace, but am not seeing > > how > > > this will correct my problem. It seems that the IEditableObject > interface > > is > > > more responsible for managing changes to an object and either committing > > or > > > discarding those changes when an edit begins or is cancelled. I will > > > probably need to get to that task next, but for now, I just want return > > the > > > correct type of object when a "new" is clicked by the user. Does the > > > IEditableObject interface handle new object as well? > > > > > > "sloan" wrote: > > > > > > > Do a google search for > > > > IEditableObject. > > > > > > > > http://www.google.com/search?hl=en&q=IEditableObject > > > > > > > > Its not trivial.... I usually go with a strongly typed dataset for > this > > > > specific reason. (the work involved with implmenting IEditableObject) > > > > > > > > > > > > "Guy Thornton" <GuyThorn***@discussions.microsoft.com> wrote in > message > > > > news:3659FE33-7008-41C5-B0CC-529232117D41@microsoft.com... > > > > > I have an application that is using Datagrids to display a > collection > > of > > > > > objects (.Net 1.x, VB.Net environment using Collection Object). The > > > > > Collection Object, lets say holds a collection of Customer Objects. > > > > > I want the datagrid to be editable, so that users can enter data > > through > > > > the > > > > > grid and have it update properties of the specific Customer object. > > > > > > > > > > Also I need for when the users clicks the new row in the datagrid > that > > the > > > > > Collection adds a new Customer object to it. The problem I am > having > > is > > > > that > > > > > when I click the new row in datagrid, I get a system.dll exception. > > > > > > > > > > What I see happening is that when new is clicked in the datagrid, > the > > > > > collection class returns a New Object(). Is there an event or > > property > > > > that > > > > > I need to implement on my Customer Objects so that it will > understand > > the > > > > > datagrids request for a new object? > > > > > > > > > > > > > > > > > > > It would be nice if I could get someone from Microsoft to help out with this
question. The only way I have been able to figure out how to make this work, is to create a strongly typed collection Show quote "Guy Thornton" wrote: > Thanks for the information. I will see what I can work out. > > "sloan" wrote: > > > > > Here's an example I found. > > > > http://www.vb-helper.com/howto_net_sort_dataset_collection.html > > > > I don't know of a C# example offhand. ( I had that one in my old bookmarks) > > > > > > > > "sloan" <sl***@ipass.net> wrote in message > > news:%23h83U0DoGHA.3348@TK2MSFTNGP03.phx.gbl... > > > > > > I ~think you need a default contructor. > > > And I think items in your Collection, have to implment the IEditable > > object. > > > > > > Buts its been over a year since I last did it, so I can't be authoratative > > > with these answers. > > > > > > > > > > > > "Guy Thornton" <GuyThorn***@discussions.microsoft.com> wrote in message > > > news:3CE948E1-77AA-4A01-BD16-790E59E947AF@microsoft.com... > > > > I should have be more specific in my description, I have implemented my > > > own > > > > Collection class that implements IList, IBindingList, and ICollection > > > > interaces. I looked at the IEditableObject interace, but am not seeing > > > how > > > > this will correct my problem. It seems that the IEditableObject > > interface > > > is > > > > more responsible for managing changes to an object and either committing > > > or > > > > discarding those changes when an edit begins or is cancelled. I will > > > > probably need to get to that task next, but for now, I just want return > > > the > > > > correct type of object when a "new" is clicked by the user. Does the > > > > IEditableObject interface handle new object as well? > > > > > > > > "sloan" wrote: > > > > > > > > > Do a google search for > > > > > IEditableObject. > > > > > > > > > > http://www.google.com/search?hl=en&q=IEditableObject > > > > > > > > > > Its not trivial.... I usually go with a strongly typed dataset for > > this > > > > > specific reason. (the work involved with implmenting IEditableObject) > > > > > > > > > > > > > > > "Guy Thornton" <GuyThorn***@discussions.microsoft.com> wrote in > > message > > > > > news:3659FE33-7008-41C5-B0CC-529232117D41@microsoft.com... > > > > > > I have an application that is using Datagrids to display a > > collection > > > of > > > > > > objects (.Net 1.x, VB.Net environment using Collection Object). The > > > > > > Collection Object, lets say holds a collection of Customer Objects. > > > > > > I want the datagrid to be editable, so that users can enter data > > > through > > > > > the > > > > > > grid and have it update properties of the specific Customer object. > > > > > > > > > > > > Also I need for when the users clicks the new row in the datagrid > > that > > > the > > > > > > Collection adds a new Customer object to it. The problem I am > > having > > > is > > > > > that > > > > > > when I click the new row in datagrid, I get a system.dll exception. > > > > > > > > > > > > What I see happening is that when new is clicked in the datagrid, > > the > > > > > > collection class returns a New Object(). Is there an event or > > > property > > > > > that > > > > > > I need to implement on my Customer Objects so that it will > > understand > > > the > > > > > > datagrids request for a new object? > > > > > > > > > > > > > > > > > > > > > > > > > > > |
|||||||||||||||||||||||