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
.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.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 ([email protected], 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.