Home All Groups Group Topic Archive Search About

ObjectDataSource not refreshing correctly from a business Object

Author
13 Apr 2007 5:58 AM
WayDownUnder
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

Author
13 Apr 2007 12:30 PM
Walter Wang [MSFT]
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<Product> s_products;

        public static List<Product> GetAllProducts()
        {
            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 (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Are all your drivers up to date? click for free checkup

Author
16 Apr 2007 1:30 AM
WayDownUnder
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


Show quoteHide quote
"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<Product> s_products;
>
>         public static List<Product> GetAllProducts()
>         {
>             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 (waw***@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
Author
16 Apr 2007 5:26 AM
Walter Wang [MSFT]
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 (waw***@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.
Author
16 Apr 2007 7:44 AM
WayDownUnder
Thanks walter ,
I found by closing the solution and re-opening it was ok
--
Life in the sun


Show quoteHide quote
"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 (waw***@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.
>
>
Author
16 Apr 2007 7:52 AM
WayDownUnder
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


Show quoteHide quote
"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 (waw***@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.
>
>
Author
16 Apr 2007 8:33 AM
Walter Wang [MSFT]
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/content/content.aspx?ContentID=2220 which
is monitored by our product team directly. Thanks for your feedback!

Regards,
Walter Wang (waw***@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.

Bookmark and Share