473,396 Members | 1,858 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,396 software developers and data experts.

ObjectDataSource not refreshing correctly from a business Object

When I link an ObjectDataSource to a business object, it appears that the
Refresh Schema button does nothing.

I have added a property to the business object and want to display this new
property on a gridview attached to my ObjectDataSource.

Tried all things including build/rebuild. Delete objectdataSource add in
again.
Still not working.
Any info would help

--
Life in the sun
Apr 13 '07 #1
6 5690
Hi,

I've done following test on my side and it's working correctly on my side:

1) Create a default web site using File System mode
2) Create a class with following content (placed to App_Code location as
prompted):

using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace myns
{
public class Product
{
private int m_id;

public int Id
{
get { return m_id; }
set { m_id = value; }
}
private string m_name;

public string Name
{
get { return m_name; }
set { m_name = value; }
}
private double m_price;

public double Price
{
get { return m_price; }
set { m_price = value; }
}
private bool m_archived;

public bool Archived
{
get { return m_archived; }
set { m_archived = value; }
}

public Product()
{
}

public Product(int id, string name, double price, bool archived)
{
m_id = id;
m_name = name;
m_price = price;
m_archived = archived;
}
}

[DataObject(true)]
public class ProductDAO
{
private static List<Products_products;

public static List<ProductGetAllProducts()
{
if (s_products == null)
{
s_products = new List<Product>();
s_products.Add(new Product(1, "first product", 11.11,
false));
s_products.Add(new Product(2, "second product", 22.22,
true));
s_products.Add(new Product(3, "third product", 33.33,
true));
s_products.Add(new Product(4, "fourth product", 44.44,
false));
}
return s_products;
}

public static Product GetProductById(int id)
{
foreach (Product p in s_products)
{
if (p.Id == id) return p;
}
return null;
}

public static void UpdateProduct(Product product)
{
if (s_products == null) throw new
ApplicationException("Products is null");

for (int i = 0; i < s_products.Count; i++)
{
if (s_products[i].Id == product.Id)
{
s_products.Insert(i, product);
s_products.RemoveAt(i + 1);
return;
}
}
throw new ApplicationException("Invalid product to update");
}

public static void DeleteProduct(Product product)
{
if (s_products == null) throw new
ApplicationException("Products is null");
for (int i = 0; i < s_products.Count; i++)
{
if (s_products[i].Id == product.Id)
{
s_products.RemoveAt(i);
return;
}
}
}
}
}
3) Compile the web site and add a GridView to Default.aspx, configure to
use the ObjectDataSource, the GridView shows 4 columns: Archived, Price,
Id, Name

4) Now add following property in the Product class

private string m_memo;

public string Memo
{
get { return m_memo; }
set { m_memo = value; }
}

5) Compile the web site again, open Default.aspx designer, select the
GridView (make sure no column is selected) and open it's smart tags menu:
select "Refresh Schema", the IDE will prompt:

=====
Refresh Fields and Keys for 'GridView1'

Would you like to regenerate the GridView column fields and data keys using
the selected data source schema? Warning: this will delete all existing
column fields.
=====

Select Yes and the GridView will have the new column "Memo".

Would you please test above steps on your side and let me know the result?
Thanks.
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.

Apr 13 '07 #2
Thanks Walter for the reply,
But my scenario is slightly different.
The Object data source is choosn for the toolbox
The ODS links to another project that has the business logic layer to expose
the getlist.
The getlist access another porject with the model in it.
Under these circumstances it doesnt work

--
Life in the sun
"Walter Wang [MSFT]" wrote:
Hi,

I've done following test on my side and it's working correctly on my side:

1) Create a default web site using File System mode
2) Create a class with following content (placed to App_Code location as
prompted):

using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace myns
{
public class Product
{
private int m_id;

public int Id
{
get { return m_id; }
set { m_id = value; }
}
private string m_name;

public string Name
{
get { return m_name; }
set { m_name = value; }
}
private double m_price;

public double Price
{
get { return m_price; }
set { m_price = value; }
}
private bool m_archived;

public bool Archived
{
get { return m_archived; }
set { m_archived = value; }
}

public Product()
{
}

public Product(int id, string name, double price, bool archived)
{
m_id = id;
m_name = name;
m_price = price;
m_archived = archived;
}
}

[DataObject(true)]
public class ProductDAO
{
private static List<Products_products;

public static List<ProductGetAllProducts()
{
if (s_products == null)
{
s_products = new List<Product>();
s_products.Add(new Product(1, "first product", 11.11,
false));
s_products.Add(new Product(2, "second product", 22.22,
true));
s_products.Add(new Product(3, "third product", 33.33,
true));
s_products.Add(new Product(4, "fourth product", 44.44,
false));
}
return s_products;
}

public static Product GetProductById(int id)
{
foreach (Product p in s_products)
{
if (p.Id == id) return p;
}
return null;
}

public static void UpdateProduct(Product product)
{
if (s_products == null) throw new
ApplicationException("Products is null");

for (int i = 0; i < s_products.Count; i++)
{
if (s_products[i].Id == product.Id)
{
s_products.Insert(i, product);
s_products.RemoveAt(i + 1);
return;
}
}
throw new ApplicationException("Invalid product to update");
}

public static void DeleteProduct(Product product)
{
if (s_products == null) throw new
ApplicationException("Products is null");
for (int i = 0; i < s_products.Count; i++)
{
if (s_products[i].Id == product.Id)
{
s_products.RemoveAt(i);
return;
}
}
}
}
}
3) Compile the web site and add a GridView to Default.aspx, configure to
use the ObjectDataSource, the GridView shows 4 columns: Archived, Price,
Id, Name

4) Now add following property in the Product class

private string m_memo;

public string Memo
{
get { return m_memo; }
set { m_memo = value; }
}

5) Compile the web site again, open Default.aspx designer, select the
GridView (make sure no column is selected) and open it's smart tags menu:
select "Refresh Schema", the IDE will prompt:

=====
Refresh Fields and Keys for 'GridView1'

Would you like to regenerate the GridView column fields and data keys using
the selected data source schema? Warning: this will delete all existing
column fields.
=====

Select Yes and the GridView will have the new column "Memo".

Would you please test above steps on your side and let me know the result?
Thanks.
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.

Apr 16 '07 #3
Hi,

By moving the Product class to a separate class library, I can now see the
issue on my side.

The only workaround I can find is to close the page's designer and re-open
it, then the "Refresh Schema" should work correctly. Would you please test
if this workaround works for you? Thanks.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Apr 16 '07 #4
Thanks walter ,
I found by closing the solution and re-opening it was ok
--
Life in the sun
"Walter Wang [MSFT]" wrote:
Hi,

By moving the Product class to a separate class library, I can now see the
issue on my side.

The only workaround I can find is to close the page's designer and re-open
it, then the "Refresh Schema" should work correctly. Would you please test
if this workaround works for you? Thanks.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Apr 16 '07 #5
Walter,
closing the designer doesnt fix the issue.
The only way I found is close the solution and go back in
--
Life in the sun
"Walter Wang [MSFT]" wrote:
Hi,

By moving the Product class to a separate class library, I can now see the
issue on my side.

The only workaround I can find is to close the page's designer and re-open
it, then the "Refresh Schema" should work correctly. Would you please test
if this workaround works for you? Thanks.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Apr 16 '07 #6
Hi,

Thanks for the quick update and sharing the workaround with the community.

This looks like a possible issue of current Visual Studio IDE not updating
the referenced assembly after it's rebuilt in IDE. I will help report to
related product team. In the meanwhile, you're also welcome to submit your
feedback at
http://connect.microsoft.com/Main/co...ContentID=2220 which
is monitored by our product team directly. Thanks for your feedback!

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Apr 16 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Trail Monster | last post by:
Ok, I've been searching the net now for several days and can't find how to do this anywhere. Version: VS 2005 Professional Release, 2.0 Framework Background: I have a complex business object...
4
by: Jim Hammond | last post by:
It would be udeful to be able to get the current on-screen values from a FormView that is databound to an ObjectDataSource by using a callback instead of a postback. For example: public void...
10
by: J055 | last post by:
Hi I've been trying out SqlCacheDependency using the ObjectDataSource and SQL Server 2005. It all works quite well with the minimum of configuration, e.g. <asp:ObjectDataSource...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
2
by: Kevin Frey | last post by:
One of my chief criticisms of validators in an ASP.NET page is that they can result in a developer re-implementing much of the "business logic" of a transaction at the page level. Assuming we...
1
by: =?Utf-8?B?cm9zczYxMw==?= | last post by:
I really hope this is not a case of "this silly thing will never work".....lots of time invested in troubleshooting this already. I have created a standard ASP.NET web form (.aspx) with several...
0
by: m.bagattini | last post by:
Hello folks, I'll try to be as much clear as I can. This is my issue: Asp.NET 2.0 page w/ FormView (later: FW), an ObjectDataSource (ODS). It works with my Business logic layer, where I have...
0
by: cmrchs | last post by:
Hi, I'm trying out Databinding to a Data Acces Layer using a GridView and ObjectDataSource-control The Update works fine but the Delete-method doesn't ??? <asp:GridView ID="GridView1"...
0
by: fig000 | last post by:
Hi, I'm using an objectdatasource. The insert procedure called by the objectdatasource is in a separate library file outside of the aspx and the codebehind that is using the objectdatasource in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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...
0
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,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.