Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.



C#
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()
        {
            //
            // TODO: Add constructor logic here
            //
        }
    }
}


Web Config : code
XML
<profile>
        <properties>
            <add name="shopping" type="shop.shopping"/>
        </properties>
    </profile>





Page code behind:
C#
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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900