G
Guest
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?
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?