Hello Friends,
Actually i am working on profiles: I have created a custom class and created profile properties in that class.
I am then inheriting that object in the web config file.
namespace shop
{
public class shopping
{
private List<CartItem> _Items = new List<CartItem>();
public List<CartItem> items
{
get { return _Items; }
}
public class CartItem
{
private string _name;
private decimal _price;
private string _description;
public string Name
{
get { return _name; }
set { _name = value; }
}
public decimal Price
{
get { return _price; }
set { _price = value; }
}
public string Description
{
get { return _description; }
set { _description = value; }
}
public CartItem()
{
}
public CartItem(string name, decimal price, string description)
{
_name = name;
_price = price;
_description = description;
}
}
public shopping()
{
}
}
}
Web Config : code
<profile>
<properties>
<add name="shopping" type="shop.shopping"/>
</properties>
</profile>
Page code behind:
void Page_PreRender()
{
gv.DataSource = Profile.shopping.items;
gv.DataBind();
}
public void add(object sender, EventArgs e)
{
shop.shopping.CartItem cart = new shop.shopping.CartItem(name.Text, decimal.Parse(price.Text),desc2.Text);
Profile.shopping.items.Add(cart);
}
- On button click i want to add items to the shopping cart. How ever i can manage that, but the main thing is: The moment the page is rendered it throws an Exception.
- Why this exception occured? because i have my data base in place. Is it something related to aspnet_regsql tool?
Please advice,
Thanks and Regards,
Rahul