Is there any way to do this without using the ObjectDataSource? (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 ObjectDataSource which means I create a class
like follows:
public class ORDataObjectBinder
{
public DataObject Select()
{
returns new object;
}
public DataObject Select(string sId)
{
returns object by custom OR/mapper;
}
public void Update(DataObject 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 ObjectDataSource as follows:
_odsProfile = new ObjectDataSource();
_odsProfile.TypeName = "ORDataObjectBinder";
_odsProfile.SelectMethod = "Select";
_odsProfile.UpdateMethod = "Update";
_odsProfile.ID = "GridProfileSource";
this.Controls.Add(_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:
ObjectDataSource 'GridProfileSource' could not find a non-generic method
'Update' that has parameters: Name, Description.
Which says I need an Update(Name, Description) method on my
ORDataObjectBinder. 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(DataObject)
method instead? 1 2127
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 objectdatasource 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 ObjectDataSource? (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 ObjectDataSource which means I create a class like follows:
public class ORDataObjectBinder { public DataObject Select() { returns new object; }
public DataObject Select(string sId) { returns object by custom OR/mapper; }
public void Update(DataObject 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 ObjectDataSource as follows: _odsProfile = new ObjectDataSource(); _odsProfile.TypeName = "ORDataObjectBinder"; _odsProfile.SelectMethod = "Select"; _odsProfile.UpdateMethod = "Update"; _odsProfile.ID = "GridProfileSource"; this.Controls.Add(_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:
ObjectDataSource 'GridProfileSource' could not find a non-generic method 'Update' that has parameters: Name, Description.
Which says I need an Update(Name, Description) method on my ORDataObjectBinder. 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(DataObject) method instead? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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: 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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |