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

Gridview and ObjectDataSource with Custom object : update problem

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

Similar topics

8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
0
by: ThePurpleCat | last post by:
Hi, I'm a newbie to ASP.NET programming but not to Visual Studio. I'm having trouble getting my Master-Details page to work. I have a page enabled GridView which is linked to a FormView control...
2
by: Greg | last post by:
Hello, I am trying to bind a GridView to a custom object I have created. First, here is what I'm trying to do: I have a wizard for adding/editing Users. When the wizard begins, a User...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
1
by: Barry L. Camp | last post by:
Hi all, Wondering if someone can help with a nagging problem I am having using a GridView and an ObjectDataSource. I have a simple situation where I am trying to delete a row from a table, but...
5
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are...
5
by: =?Utf-8?B?QWRhciBXZXNsZXk=?= | last post by:
Hi All, I have a GridView inside the EditItemTemplate of a FormView. Both FormView and GridView are data bound using an ObjectDataSource. When the FormView's ObjectDataSource object has a...
4
by: tim.cavins | last post by:
I have a GridView populated by an ObjectDataSource. I am having issues passing the parameters to the objectdatasource. I have verified that the method is being called but none of the parameters...
0
by: steve | last post by:
I have been fighting with trying to update a GridView for a while. I don't want to use the "built-in" way to do it because I am using business layer methods for updating and deleteing and I don't...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
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,...
0
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...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.