By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,908 Members | 2,055 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,908 IT Pros & Developers. It's quick & easy.

2-Way Databinding without the DataSources from 2.0

P: n/a
L.S.,

Hello is there a way to implement 2-way databinding without using the
datasources from dotnet 2.0. Why would you ask? Now that's simple.

I've created an object model with BusinessObjects and I don't want to write
an separate provider layer for the datasources. This is because I loose all
the benefits of my objectmodel.

Are there other developers who think this way?

Thanx in advance.

Greetz,
Jan 24 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
When I was programming in ASP.NET 1.1, I implemented 2-way data binding using
my own custom data bound tem plated control (or creating a composite control
out of the repeater). This allowed me to use templates against a BLL. In
ASP.NET 2.0 I found, so far, the objectdatasource to be a very helpful for
RAD. I think it is a great improvement.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Joey Chömpff" wrote:
L.S.,

Hello is there a way to implement 2-way databinding without using the
datasources from dotnet 2.0. Why would you ask? Now that's simple.

I've created an object model with BusinessObjects and I don't want to write
an separate provider layer for the datasources. This is because I loose all
the benefits of my objectmodel.

Are there other developers who think this way?

Thanx in advance.

Greetz,

Jan 24 '06 #2

P: n/a
Yeah I did something like that in asp.net 1.1. But I'm not happy with the
design
of Microsoft about the ObjectDataSource, because if you use an genuine
objectmodel u can't use the ObjectDataSource for Updating/Deleting/Inserting
you can only use Select.

If you realy want to use the objectdatasource you'lle have to write an
CRUD-layer who is very close of the UI (in my meaning design fault),
this layer must implement some CRUD methods. These CRUD-methods can use your
normal businesslayer.

I had hoped Microsoft created an independent layer for binding
objects/datasets to controls (ASP.NET or WinForms), now I will have to write
all those things myself.

By the way I'm interested in your "own custom data bound tem plated control
", because my own controls where not 2 way.

Greetz,

"Phillip Williams" wrote:
When I was programming in ASP.NET 1.1, I implemented 2-way data binding using
my own custom data bound tem plated control (or creating a composite control
out of the repeater). This allowed me to use templates against a BLL. In
ASP.NET 2.0 I found, so far, the objectdatasource to be a very helpful for
RAD. I think it is a great improvement.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Joey Chömpff" wrote:
L.S.,

Hello is there a way to implement 2-way databinding without using the
datasources from dotnet 2.0. Why would you ask? Now that's simple.

I've created an object model with BusinessObjects and I don't want to write
an separate provider layer for the datasources. This is because I loose all
the benefits of my objectmodel.

Are there other developers who think this way?

Thanx in advance.

Greetz,

Jan 24 '06 #3

P: n/a
Hi Joey,

I am not sure why you say that you “can't use the ObjectDataSource for
Updating/Deleting/Inserting” and that “you can only use Select.” The demos
on my website www.webswapp.com update the records using an objectDataSource
that updates the data through a BLL. You can use a BLL class by specifying a
value for the DataObjectTypeName.

For example in this demo
http://www.webswapp.com/CodeSamples/...idView_2c.aspx I pass to the
update method a customized class and defines parameters that the
objectDataSource would set within that class.

As for my custom dataBound Templated Control that I referred to in the
previous message, if you are interested in creating one you might:

1- read this article for Scott Mitchell on creating databound templated
controls:
http://msdn.microsoft.com/library/de...edcontrols.asp

2- Create your own templates (as the sample in step 1 demonstrated)

3- For controls, such as textboxes, that are not databound by default, add a
step that is not in Scott’s demo where you create your own custom controls of
the existing server controls:
a. Persist the content in the ViewState upon setting a property of
the control
b. Handle the MyBase.DataBinding event to bind the content to the
control then
c. Handle other events upon change of data inside the server
control, for example,
i. MyBase.TextChanged event for the TextBox server control:
during this step you would call a method that would update the data within
the class associated with this control

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Joey Chömpff" wrote:
Yeah I did something like that in asp.net 1.1. But I'm not happy with the
design
of Microsoft about the ObjectDataSource, because if you use an genuine
objectmodel u can't use the ObjectDataSource for Updating/Deleting/Inserting
you can only use Select.

If you realy want to use the objectdatasource you'lle have to write an
CRUD-layer who is very close of the UI (in my meaning design fault),
this layer must implement some CRUD methods. These CRUD-methods can use your
normal businesslayer.

I had hoped Microsoft created an independent layer for binding
objects/datasets to controls (ASP.NET or WinForms), now I will have to write
all those things myself.

By the way I'm interested in your "own custom data bound tem plated control
", because my own controls where not 2 way.

Greetz,

"Phillip Williams" wrote:
When I was programming in ASP.NET 1.1, I implemented 2-way data binding using
my own custom data bound tem plated control (or creating a composite control
out of the repeater). This allowed me to use templates against a BLL. In
ASP.NET 2.0 I found, so far, the objectdatasource to be a very helpful for
RAD. I think it is a great improvement.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Joey Chömpff" wrote:
L.S.,

Hello is there a way to implement 2-way databinding without using the
datasources from dotnet 2.0. Why would you ask? Now that's simple.

I've created an object model with BusinessObjects and I don't want to write
an separate provider layer for the datasources. This is because I loose all
the benefits of my objectmodel.

Are there other developers who think this way?

Thanx in advance.

Greetz,

Jan 24 '06 #4

P: n/a
Phillip,

First of all thanks for your anwser. When I create business-objectmodel I
make something like this:

public class Address
{
public Address(int id) { Dal.Get() }

public bool Delete() { Dal.Delete() }

public bool Save() { Dal.Save() }

public static GetAllAddresses() { Dal.GetAllAddresses() }

private int _id = int.MinValue;
public int Id { get { return _id } }

...some other properties and methods...
}

If you do it like this way, and this is a normal businessobjectmodel,
you can't use this class in the ObjectDataSource, you'll have to write
an descendant or create an provider who gets ands sets businessobjects
for u. Something like:

public class AddressProvider
{
public static bool Update(int id, string city, etc)
{
Address a = new Address(id);
a.City = city;
return a.Save();
}

... etc .....
}

I'm convinced that this isn't the right way to do it, but if it can't be done
I will have to work with it.

I hope you understand me now ;-)

Greetz,

Joey Chömpff
Jan 24 '06 #5

P: n/a
Hi Joey,

Actually, your class would work just fine if you were to make one simple
modification: namely a default constructor. Note that you need “set”
statements for the properties whose values are to be updated by parameters
collection of the objectDatasource. For example your class can look like
this:

public class Address
{

public Address(){
//this default constructor is essential for the
objectdatasource //
}

// the rest of your class as is; only make sure you have set statements
// for the properties that the ObjectDataSource would pass from the
// UpdateParameters collection
}

You can look at the demos on my website for a proof of this concept.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Joey Chömpff" wrote:
Phillip,

First of all thanks for your anwser. When I create business-objectmodel I
make something like this:

public class Address
{
public Address(int id) { Dal.Get() }

public bool Delete() { Dal.Delete() }

public bool Save() { Dal.Save() }

public static GetAllAddresses() { Dal.GetAllAddresses() }

private int _id = int.MinValue;
public int Id { get { return _id } }

...some other properties and methods...
}

If you do it like this way, and this is a normal businessobjectmodel,
you can't use this class in the ObjectDataSource, you'll have to write
an descendant or create an provider who gets ands sets businessobjects
for u. Something like:

public class AddressProvider
{
public static bool Update(int id, string city, etc)
{
Address a = new Address(id);
a.City = city;
return a.Save();
}

... etc .....
}

I'm convinced that this isn't the right way to do it, but if it can't be done
I will have to work with it.

I hope you understand me now ;-)

Greetz,

Joey Chömpff

Jan 24 '06 #6

P: n/a
Phillip,

I can live with an default constructor, but how do you handle
readonly fields like Id's, etc. These fields are set by the dal or
the businessobject itself and cannot be modified from outside.

Could u give me an working example of your BusinessLayer?

Greetz,

Joey Chömpff
Jan 24 '06 #7

P: n/a
Ok… I see what you mean… you are right… in your scenario; you will have to
write a descendant class or a provider to be able to utilize your classes in
the ObjectDataSource server control.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Joey Chömpff" wrote:
Phillip,

I can live with an default constructor, but how do you handle
readonly fields like Id's, etc. These fields are set by the dal or
the businessobject itself and cannot be modified from outside.

Could u give me an working example of your BusinessLayer?

Greetz,

Joey Chömpff

Jan 24 '06 #8

P: n/a
Phillip,

Thanx for thinking with me,

I've have an solution but it isn't a perfect one.
I have made partial classes of my businessobjects and newed the properties
who are readonly. Then i made an Update, Delete and Insert methods on the
partial classes who accepts a parameter of the partial class.

I hope that MS creates an independent layer for databinding in the near
future.

Greetz,

Joey Chömpff
Jan 24 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.