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

Home Posts Topics Members FAQ

Gridview and ObjectDataSourc e with Custom object : update problem

Hello,
I'm using a gridview with objectdatasourc e 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 6776
Olivier,

that is a known limitation of the ObjectDataSourc e. 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 objectdatasourc e 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<ProductGet AllProducts()
{
List<Productlis t = 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="I d"
AutoGenerateCol umns="False" DataSourceID="O bjectDataSource 1" >
<Columns>
<asp:CommandFie ld ShowEditButton= "True" />
<asp:BoundFie ld DataField="Id" HeaderText="Id"
SortExpression= "Id" ReadOnly="True" />
<asp:BoundFie ld DataField="Code " HeaderText="Cod e"
SortExpression= "Code" />
<asp:BoundFie ld DataField="Name " HeaderText="Nam e"
SortExpression= "Name" />
</Columns>
</asp:GridView>
<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
DataObjectTypeN ame="mynamespac e.Product"
SelectMethod="G etAllProducts" TypeName="mynam espace.Products "
UpdateMethod="U pdate">
</asp:ObjectDataS ource>

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
5034
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 select, remember it, and then use it in the update. It works just fine when I have full control of the whole process. I want to do the same for my GridView/SqlDataSource combinations. I typically select from a view and update the corresponding...
0
4741
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 through an objectdatasource. The paging on my GridView works fine except that when I change the page the FormView does not update. I tried setting the selectedindex to 0 in the GridView's PageIndexChanged event and manually binding the formview...
2
8987
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 object (custom class) is created, and properties are populated in each step of the wizard. In one of the steps, the User is assigned to 1 or more Programs. Assigned Programs are stored by the User object in a List, and displayed in a GridView in the...
8
18081
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 display data in a "GridView" which is tied to an "ObjectDataSource". In turn, this ObjectDatasource gets it's data from a strongly-typed business object within my code.
1
8576
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 it doesn't seem to work at all. Below is my ASP.NET page, and further below, my VB.NET method that I am trying to call: <div id="admin-faq" class="page"> <h2>Site FAQs (Frequently Asked Questions)</h2>
5
2648
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 simply working with objects in memory. So, it appears as though Microsoft requires that our datamapper classes reside inside a folder called "App_Code", and NO WHERE ELSE. So, has anyone successfully been able to place their datamappers in a...
5
4678
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 SelectParameters with a SessionParameter in the parameters collection and the object stored in the Session is a reference type, the DataGrid fails to enter Line Editing mode. Is this a bug? Is there a workaround for this problem?
4
6074
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 are being populated. Integers are being passed as 0 and strings are empty regardless of what I changed them to in Edit mode on the GridView. My object method to perform the update:
0
4273
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 want to have my parameter names in those methods have to be "original_Parametername" or even if I change the OldValuesParameterFormatString to get rid of the "original" I would still have just "Parametername". I think most people user parameters...
0
8609
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
9169
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
9030
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...
0
7738
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5861
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
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...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.