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

Gridview and ObjectDataSource with Custom object : update problem

P: n/a
Hello,
I'm using a gridview with objectdatasource and custom objects collections
SELECT/INSERT/UPDATE/DELETE methods are using custom objects as parameters.
This is working fine. But I have a problem with the object that is passed
back to the update method. It contains some of the properties of the
original object sent during the SELECT method, but is missing others ! How
can I ensure that all original object properties not modified are also set
in the object given to the update mehod ?
TIA.
Sep 29 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Olivier,

that is a known limitation of the ObjectDataSource. Here you have more
information and a possible solution using my EODS component:

http://www.manuelabadia.com/livedemo...peControl.aspx

Best regards,
Manuel Abadia
http://www.manuelabadia.com

Olivier Matrot wrote:
Hello,
I'm using a gridview with objectdatasource and custom objects collections
SELECT/INSERT/UPDATE/DELETE methods are using custom objects as parameters.
This is working fine. But I have a problem with the object that is passed
back to the update method. It contains some of the properties of the
original object sent during the SELECT method, but is missing others ! How
can I ensure that all original object properties not modified are also set
in the object given to the update mehod ?
TIA.
Sep 29 '06 #2

P: n/a
Hi Olivier,

Using a simple business object and DAL class doesn't reproduce the issue
you're experiencing:

namespace mynamespace
{
public class Product
{
private int _id;

public int Id
{
get { return _id; }
set { _id = value; }
}
private string _code;

public string Code
{
get { return _code; }
set { _code = value; }
}
private string _name;

public string Name
{
get { return _name; }
set { _name = value; }
}

public Product()
{
}

public Product(int p_id, string p_code, string p_name)
{
_id = p_id;
_code = p_code;
_name = p_name;
}
}

public class Products
{
public List<ProductGetAllProducts()
{
List<Productlist = new List<Product>();
for (int i = 0; i < 10; i++) {
list.Add(new Product(i, "code" + i.ToString(), "name" +
i.ToString()));
}
return list;
}

public void Update(Product p)
{
}
}
}

<asp:GridView ID="GridView1" runat="server" DataKeyNames="Id"
AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" >
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="Id" HeaderText="Id"
SortExpression="Id" ReadOnly="True" />
<asp:BoundField DataField="Code" HeaderText="Code"
SortExpression="Code" />
<asp:BoundField DataField="Name" HeaderText="Name"
SortExpression="Name" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DataObjectTypeName="mynamespace.Product"
SelectMethod="GetAllProducts" TypeName="mynamespace.Products"
UpdateMethod="Update">
</asp:ObjectDataSource>

Your project is certainly more complicated than this. Would you please
create a reproducible project and post it here or send it to me directly?
Thank you.
Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 2 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.