473,320 Members | 2,098 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,320 software developers and data experts.

2-Way Databinding without the DataSources from 2.0

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
8 1819
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mr Newbie | last post by:
Ive got the basic idea behind DataBinding Expressions, but I have a couple of questions, Ok its four actually :) Q1.) It would appear that if you use Page.DataBind that all child controls and...
4
by: pmcguire | last post by:
Can someone explain to me the difference between these two bindings? dim b as Binding b=New Binding(dsMyDataset.tblMyTable, "colMyColumn") b=New Binding(dsMyDataset,...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
5
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I...
0
by: Owen Richardson | last post by:
I have a page that displays a news article in a form view feeding off a datasource that just picks up the id from a query string. I want to add functionality for related links - so i created a...
19
by: cpnet | last post by:
I'm using VS2005, C#, ASP.NET 2.0. I'm trying to create a report using SQL Reporting Services (to be used in local mode so I don't have to deal with SQL Server). When I create a new report in my...
4
by: =?Utf-8?B?bXVzb3NkZXY=?= | last post by:
Hi guys Just a general query regarding using the AccessDataSource within a website which uses a MasterPage. The layout of my content page is as follows... <asp:Content ID="Content1"...
3
by: Martin Frey | last post by:
Hello guys, im new to asp.net and im trying to get me used to it. I've managed to create webpages with detailviews, databinding and datasources. Adding or inserting data went very well and, after...
1
by: Wingot | last post by:
Hey, I have an application codenamed WingFlex. It has a number of aspects to it, but the prudent parts for this problem are all within the "Client" Schema. The Client schema has three tables...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.