473,588 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Two-way databinding to Business Object (ASP.NET 2.0)

Is there any way to do this without using the ObjectDataSourc e? (Apologies
for the long post)

I have a simple data object:
public class TestDO
{
public TestDO() {}
public ID { get; set; }
public Name { get; set; }
public Description { get; set; }
}

Under .NET 1.1 I could bind directly to this object for one-way databinding,
although I built in support using custom controls for two-way databinding.

Now, I seem to have to use the ObjectDataSourc e which means I create a class
like follows:

public class ORDataObjectBin der
{
public DataObject Select()
{
returns new object;
}

public DataObject Select(string sId)
{
returns object by custom OR/mapper;
}

public void Update(DataObje ct doUpdated)
{
update data object using custom OR/mapper;
}
}

I then create a FormView in a page with bound controls for Name and
Description, create an ObjectDataSourc e as follows:
_odsProfile = new ObjectDataSourc e();
_odsProfile.Typ eName = "ORDataObjectBi nder";
_odsProfile.Sel ectMethod = "Select";
_odsProfile.Upd ateMethod = "Update";
_odsProfile.ID = "GridProfileSou rce";
this.Controls.A dd(_odsProfile) ;

Now, I can load the FormView up just fine, but when I click the Save button,
which fires off the Update method I get this error:

ObjectDataSourc e 'GridProfileSou rce' could not find a non-generic method
'Update' that has parameters: Name, Description.

Which says I need an Update(Name, Description) method on my
ORDataObjectBin der. If I only have Name bound control in the Formview it
wants an Update(Name) method.

However, I DO NOT WANT TO DO THIS! This would be a maintanence nightmare as
if I have to have an update method, with all the parameter permutations, for
every object in my system... geesh, thats not very handy at all.

Does anyone know how I can get the system to just use the Update(DataObje ct)
method instead?

Nov 19 '05 #1
1 2139
In regards to your last question, you should be able to just have a function

Public void Update(TestDo x)

Since u didn't include all your code make sure your class is structured with
private field/public property. It might also have to have a new method.

I have used the objectdatasourc e update with passing it just the object
several times and it works great as long as it isn't a complex object.


"thzero" wrote:
Is there any way to do this without using the ObjectDataSourc e? (Apologies
for the long post)

I have a simple data object:
public class TestDO
{
public TestDO() {}
public ID { get; set; }
public Name { get; set; }
public Description { get; set; }
}

Under .NET 1.1 I could bind directly to this object for one-way databinding,
although I built in support using custom controls for two-way databinding.

Now, I seem to have to use the ObjectDataSourc e which means I create a class
like follows:

public class ORDataObjectBin der
{
public DataObject Select()
{
returns new object;
}

public DataObject Select(string sId)
{
returns object by custom OR/mapper;
}

public void Update(DataObje ct doUpdated)
{
update data object using custom OR/mapper;
}
}

I then create a FormView in a page with bound controls for Name and
Description, create an ObjectDataSourc e as follows:
_odsProfile = new ObjectDataSourc e();
_odsProfile.Typ eName = "ORDataObjectBi nder";
_odsProfile.Sel ectMethod = "Select";
_odsProfile.Upd ateMethod = "Update";
_odsProfile.ID = "GridProfileSou rce";
this.Controls.A dd(_odsProfile) ;

Now, I can load the FormView up just fine, but when I click the Save button,
which fires off the Update method I get this error:

ObjectDataSourc e 'GridProfileSou rce' could not find a non-generic method
'Update' that has parameters: Name, Description.

Which says I need an Update(Name, Description) method on my
ORDataObjectBin der. If I only have Name bound control in the Formview it
wants an Update(Name) method.

However, I DO NOT WANT TO DO THIS! This would be a maintanence nightmare as
if I have to have an update method, with all the parameter permutations, for
every object in my system... geesh, thats not very handy at all.

Does anyone know how I can get the system to just use the Update(DataObje ct)
method instead?

Nov 19 '05 #2

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

Similar topics

6
3562
by: John Bailey | last post by:
I have a web page with a formview, and a multiview in the formview. When I databind the values inside the multiview views, there is no option for two-way databinding. The form populates fine, but when it calls the update method, it calls it with no parameters. Is there just no support for two-way databinding inside these controls, or is there a technique I am missing?
1
2813
by: dieter | last post by:
Two-way databinding (as described in http://dotnetjunkies.com/QuickStartv20/aspnet/doc/data/templates.aspx) works fine for me if I use it within aspx-files. However, I would like to use it my codehind file and I don't know how to get it work since I did not find any equivalent for "Bind" to use in my ITemplate derived class. For my ItemTemplate, I use (int)((DataRowView)container.DataItem) as equivalent to <%# Eval ...%>
2
4259
by: John R. Lewis | last post by:
I posted this yesterday with a different email address. I am reposting with my fake-address as given to me by Microsoft so that I can be guraranteed a response from a support representative. Sorry for the repost. I'd like to make use of the asp:Wizard control to present a step-by-step guided experience for my user to fill out a complicated data-entry form. I'd like to make use of two-way databinding provided by the asp:FormView control...
1
18821
by: Dave A | last post by:
Hi, I am struggling with two way databinding in WinForms and the DataGridView. I am binding to business object classes (rather than datatables). If I have a collection of these business objects that is the datasource of a DataBinding that is bound to a DataGridView (WinForms) then I was expecting that any change to the data would be reflected in the DataGridView (in other words I was expecting the 2 way databinding to actually...
2
2329
by: Toma Marinov | last post by:
Hello ! My question is about the Two-Way DataBinding in Win Forms VS.2005 (C# or VB.Net). I mean the process when the value was updated in the control and this change must be reflected in the datasource, and vitce versa.....Can someone give me some links about this issue, because I found a lot of info but only about Web Forms, and about complex data binding in Win Forms but about two-way databinding - nothing.... I'll be very...
0
1482
by: AM | last post by:
The following block of code defines a FormView control "FormView1" with an EditItemTemplate which has a Label and a TextBox control within it. While the Label "RequestIDLabel1" has one-way data-binding to the underlying column "RequestID", the TextBox "RequestDateTextBox" has two-way data-binding to the underlying column. If I were to generate the EditItemTemplate dynamically at runtime, and add the Label and TextBox controls at...
0
2683
by: witek | last post by:
I am lost. There is a dataTable with data which I want to dispaly in GridView. dataTable is not connected to any database. Just dataTable with data. There is a class wich is used as column template //------------------------------------------------------------------------------------------------------- public class TextBoxTemplate :ITemplate { DataControlRowType m_rowType;
0
1123
by: =?Utf-8?B?TWlrZSBNaWxpYW4=?= | last post by:
I have a dropdownlist control in a formview and I am trying to enable 2 way databinding. Only, the option is not available. I look at the "Edit Databinding" option of another DDL control in the same formview and it is available The only difference is that the DDL (where the two-way data binding property in not available) is inside a panel control. Would a DDL inside a panel control cause the two-way data binding property to be...
0
1321
by: =?Utf-8?B?cGhpbGptY2c=?= | last post by:
I've seen this question asked 100 times, but with no reasonable answer, other than to extend a control etc. Sorry if I'm going over old ground. I've a DropDownList inside a FormView control, which is hooked up to a GridView. The contents of the DropDownList are being built from an ObjectDataSource using business objects. Problem is, I'm binding the DropDownList's SelectedValue to a property of type int?, and and where adding...
0
7860
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8222
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8354
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8223
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5726
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3847
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1458
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.