G
Guest
Hello,
I am trying to bind a GridView to a custom object I have created. First,
here is what I'm trying to do:
I have a wizard for adding/editing Users. When the wizard begins, a User
object (custom class) is created, and properties are populated in each step
of the wizard. In one of the steps, the User is assigned to 1 or more
Programs. Assigned Programs are stored by the User object in a List, and
displayed in a GridView in the step. At the end of the wizard, the User is
saved to the database.
I'm pretty new to asp.net 2.0, but it seemed that an easy way to handle this
would be to bind the GridView to the User object via an ObjectDataSource.
Since I've stored the Programs in a List, it's easy to create a Select method
in the User class that returns this List to the ObjectDataSource. Methods to
insert, update, and delete are not too complicated either.
The problem is that it appears that the ObjectDataSource will create a new
User object each time it is called upon to select, insert, update, or delete
Program assignments. What I want it to do is to bind to the *instance* of
the User object that I have created in the wizard - since the Program
assignments haven't been saved to the database yet, this is the only place to
retrieve this data from.
So my questions are:
1. Is there any way to bind an ObjectDataSource to an instance of a custom
object?
2. Is there a better way of attacking this problem? (I have other ideas,
but they will all required substantially more coding. But perhaps I'm going
about this all wrong...)
Thank you,
Greg
I am trying to bind a GridView to a custom object I have created. First,
here is what I'm trying to do:
I have a wizard for adding/editing Users. When the wizard begins, a User
object (custom class) is created, and properties are populated in each step
of the wizard. In one of the steps, the User is assigned to 1 or more
Programs. Assigned Programs are stored by the User object in a List, and
displayed in a GridView in the step. At the end of the wizard, the User is
saved to the database.
I'm pretty new to asp.net 2.0, but it seemed that an easy way to handle this
would be to bind the GridView to the User object via an ObjectDataSource.
Since I've stored the Programs in a List, it's easy to create a Select method
in the User class that returns this List to the ObjectDataSource. Methods to
insert, update, and delete are not too complicated either.
The problem is that it appears that the ObjectDataSource will create a new
User object each time it is called upon to select, insert, update, or delete
Program assignments. What I want it to do is to bind to the *instance* of
the User object that I have created in the wizard - since the Program
assignments haven't been saved to the database yet, this is the only place to
retrieve this data from.
So my questions are:
1. Is there any way to bind an ObjectDataSource to an instance of a custom
object?
2. Is there a better way of attacking this problem? (I have other ideas,
but they will all required substantially more coding. But perhaps I'm going
about this all wrong...)
Thank you,
Greg