473,387 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

ObjectDataSource with Complex Objects and 2 way Databinding

Ok, I've been searching the net now for several days and can't find how to do
this anywhere.

Version:
VS 2005 Professional Release, 2.0 Framework

Background:
I have a complex business object Employee that contains public properties
and several nested objects such as a Spouse object and a List of Coverage
objects.
All data access goes through a DAL

I'm currently able to use an objectdatasource to populate a gridview control
with employee information, displaying the "base" employee information binds
and works like normal, however inorder to display data from one of the nested
objects it gets a little tricky. Currently I am using a template column and
custom databinding expression such as

DirectCast(Container.DataItem, Employee).Spouse.Name

Problem 1:
This works for displaying the data but does not facilate updating. The
binding is only 1 way, i can't figure out how to use the 2 way Bind("asdlfj")
expression to work with a complex object.

Problem 2:
When the objectdatasource then calls the update Function it passes an
Employee object as the parameter. The passed in employee object's base
properties are fine, however all the nested object properties are set to
Nothing, I was able to fix this by changing the class declacration from
Public Class Spouse to

<Serializable()> Public Class Spouse

I am not real familiar with Serialization and what other effects this has on
my class though. An explanation of what this is doing and if it is the
correct way of doing this would be appreciated.
Letting off steam:
I can't believe that Microsoft would promote the objdatasource as much as it
seems they are if it can't easily handle complex object structures. If the
application is complex enough to justify a 3+ tier design then chances are
the objects are gonna be complex. . . . . If 2 way data binding isnt'
possible with complex objects then the objectdatasource is a complete waste.
Hopefully i'm wrong and this all works, in which case it will be VERY nice.

Thanks for your help in advance.

Nov 19 '05 #1
5 3453
you are supposed to supply objectdatasource with interfaces to you BI
object that it can use. it wants enum collections that it can update, and
methods to call on select/update/delete and modify updates to these
collections.

-- bruce (sqlwork.com)

"Trail Monster" <Trail Mo*****@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
Ok, I've been searching the net now for several days and can't find how to
do
this anywhere.

Version:
VS 2005 Professional Release, 2.0 Framework

Background:
I have a complex business object Employee that contains public properties
and several nested objects such as a Spouse object and a List of Coverage
objects.
All data access goes through a DAL

I'm currently able to use an objectdatasource to populate a gridview
control
with employee information, displaying the "base" employee information
binds
and works like normal, however inorder to display data from one of the
nested
objects it gets a little tricky. Currently I am using a template column
and
custom databinding expression such as

DirectCast(Container.DataItem, Employee).Spouse.Name

Problem 1:
This works for displaying the data but does not facilate updating. The
binding is only 1 way, i can't figure out how to use the 2 way
Bind("asdlfj")
expression to work with a complex object.

Problem 2:
When the objectdatasource then calls the update Function it passes an
Employee object as the parameter. The passed in employee object's base
properties are fine, however all the nested object properties are set to
Nothing, I was able to fix this by changing the class declacration from
Public Class Spouse to

<Serializable()> Public Class Spouse

I am not real familiar with Serialization and what other effects this has
on
my class though. An explanation of what this is doing and if it is the
correct way of doing this would be appreciated.
Letting off steam:
I can't believe that Microsoft would promote the objdatasource as much as
it
seems they are if it can't easily handle complex object structures. If
the
application is complex enough to justify a 3+ tier design then chances are
the objects are gonna be complex. . . . . If 2 way data binding isnt'
possible with complex objects then the objectdatasource is a complete
waste.
Hopefully i'm wrong and this all works, in which case it will be VERY
nice.

Thanks for your help in advance.

Nov 19 '05 #2
Yeah....

I'm having a similar problem. I've not been able to find anywhere more
details on the Bind syntax in relation to nested business objects
(don't even get me started on whats involved in getting business
objects with Collections as properties to one way bind ~ let alone two
way binding).

Re your second problem, I eventually decided to go with static helper
classes within my App_Code folder. Essentially these classes are
designed to be used solely by the ObjectDataSource and have those
lovely 100 parameter long (I'm exagerating a little) static methods for
populating the Business Object. As opposed to creating BO's that have
public default constructors etc etc

I think MS documentation could be a little clearer on what you can and
can't acheive with the ObjectDataSource. And maybe rename the control
to the SimpleObjectDataSource :-p

Hope this helps,

Andy
http://workingandy.blogspot.com

Nov 19 '05 #3
Bruce,

I have already set the select and update functions in the objectdatasource.
They are getting called correctly it just isn't doing the 2 way databinding
on nested object properties. Everything works great on a with a simple flat
object. . .
"Bruce Barker" wrote:
you are supposed to supply objectdatasource with interfaces to you BI
object that it can use. it wants enum collections that it can update, and
methods to call on select/update/delete and modify updates to these
collections.

-- bruce (sqlwork.com)

"Trail Monster" <Trail Mo*****@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
Ok, I've been searching the net now for several days and can't find how to
do
this anywhere.

Version:
VS 2005 Professional Release, 2.0 Framework

Background:
I have a complex business object Employee that contains public properties
and several nested objects such as a Spouse object and a List of Coverage
objects.
All data access goes through a DAL

I'm currently able to use an objectdatasource to populate a gridview
control
with employee information, displaying the "base" employee information
binds
and works like normal, however inorder to display data from one of the
nested
objects it gets a little tricky. Currently I am using a template column
and
custom databinding expression such as

DirectCast(Container.DataItem, Employee).Spouse.Name

Problem 1:
This works for displaying the data but does not facilate updating. The
binding is only 1 way, i can't figure out how to use the 2 way
Bind("asdlfj")
expression to work with a complex object.

Problem 2:
When the objectdatasource then calls the update Function it passes an
Employee object as the parameter. The passed in employee object's base
properties are fine, however all the nested object properties are set to
Nothing, I was able to fix this by changing the class declacration from
Public Class Spouse to

<Serializable()> Public Class Spouse

I am not real familiar with Serialization and what other effects this has
on
my class though. An explanation of what this is doing and if it is the
correct way of doing this would be appreciated.
Letting off steam:
I can't believe that Microsoft would promote the objdatasource as much as
it
seems they are if it can't easily handle complex object structures. If
the
application is complex enough to justify a 3+ tier design then chances are
the objects are gonna be complex. . . . . If 2 way data binding isnt'
possible with complex objects then the objectdatasource is a complete
waste.
Hopefully i'm wrong and this all works, in which case it will be VERY
nice.

Thanks for your help in advance.


Nov 19 '05 #4

My employee object contains

Public Property Coverages() As List(Of Coverage)
Get
Return _Coverages
End Get
Set(ByVal value As List(Of Coverage))
_Coverages = value
End Set
End Property

I am able to use the following syntax to 1 way Bind to the Coverage
properties in the collection

DirectCast(Container.Dataitem, Employee).Coverages(integer index).Name

However what i need to be able to do is put nest a gridview in a template
column and Bind the whole collection to the grid.

Have u done anything like that?


"as******@gmail.com" wrote:
Yeah....

I'm having a similar problem. I've not been able to find anywhere more
details on the Bind syntax in relation to nested business objects
(don't even get me started on whats involved in getting business
objects with Collections as properties to one way bind ~ let alone two
way binding).

Re your second problem, I eventually decided to go with static helper
classes within my App_Code folder. Essentially these classes are
designed to be used solely by the ObjectDataSource and have those
lovely 100 parameter long (I'm exagerating a little) static methods for
populating the Business Object. As opposed to creating BO's that have
public default constructors etc etc

I think MS documentation could be a little clearer on what you can and
can't acheive with the ObjectDataSource. And maybe rename the control
to the SimpleObjectDataSource :-p

Hope this helps,

Andy
http://workingandy.blogspot.com

Nov 19 '05 #5
i have exctly the same proble, but i culdn`t fix it with [Serializable()]. iŽll be very gracefullwith any help

From http://www.developmentnow.com/g/8_20...atabinding.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Jan 12 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: | last post by:
I've defined an ObjectDataSource against a dataset, and I can bind the ObjectDataSource's members to data controls. I'm wondering how to take the values in an ObjectDataSource and...
12
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press...
2
by: David Jessee | last post by:
I've been taking this approach when working with business entity objects: 1) Determine the ID of the object you need to work with (e.g. Invoice) 2) Get the Object instance of the Invoice...has a...
0
by: family | last post by:
I have few classes in my business layer like: Country: CountryId (int) CountryName (string) CountryManager: GetAllCountry AddCountry RemoveCountry
9
by: J055 | last post by:
Hi I'm trying to get an instance of UserLists to persist after it's been used by the GridView. I understand from the documentation that The OnObjectCreated event allows access to the instance. I...
0
by: Kevin | last post by:
Hi my name is Kevin I am currently working on a Asp 2.0 project and im having some ObjectDataSource Problems The thing is i have a Class called User and a Bussiness Logic Layer FcUser with...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
8
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the...
5
by: cmrchs | last post by:
Hi, I'm trying out Databinding to a Data Acces Layer using a ObjectDataSource-control The Update works fine but the Delete-method doesn't. when debugging I see that my productID-parameter is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.