View Single Post
  #1 (permalink)  
Old April 23rd, 2006, 10:41 AM
jazzcatone jazzcatone is offline
Authorized User
Points: 239, Level: 4
Points: 239, Level: 4 Points: 239, Level: 4 Points: 239, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem With Inheritance

  Hello and thank you for taking a moment to read this message.The practice of inheritance is something as a developer I am still struggling with a little bit. I have a page called productcatalog.aspx. It contains the following line of code.

<%@ Page language="c#" Codebehind="productcatalog.aspx.cs" AutoEventWireup="false" Inherits="ShoppingCartCookies.WebForm1" %>
Everytime I go to compile VS 2005 throws me the following build error:

Error 2 Could not load type'ShoppingCartCookies.WebForm1'. C:\Documents and Settings\Jason Livengood\My Documents\Visual Studio 2005\WebSites\WebSite8\productcatalog.aspx 1

I was wondering if anybody could tell me where my mistake is. I would appreciate any help anybody can give. Below is my codebehind for the page.

Thank You,

Jason


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace ShoppingCartCookies
{
    public class WebForm1 : System.Web.UI.Page

    {
        protected System.Web.UI.WebControls.Button Button1;
        protected System.Web.UI.WebControls.DataGrid DataGrid1;

        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindGrid();
            }
        }


        private void BindGrid()
        {
            SqlDataAdapter da = new SqlDataAdapter("select * from products", @"data source=.\vsdotnet;initial catalog=northwind;user id=sa");
            DataSet ds = new DataSet();
            da.Fill(ds, "products");

            DataGrid1.DataSource = ds;
            DataGrid1.DataBind();
        }

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexCh anged);
            this.Button1.Click += new System.EventHandler(this.Button1_Click);
            this.Load += new System.EventHandler(this.Page_Load);

        }
        #endregion

        private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            ArrayList arr;
            if (Session["mycart"] != null)
            {
                arr = (ArrayList)Session["mycart"];
            }
            else
            {
                arr = new ArrayList();
                Session["mycart"] = arr;
            }

            CShoppingCartItem item = new CShoppingCartItem();
            item.ProductID = int.Parse(DataGrid1.SelectedItem.Cells[1].Text);
            item.ProductName = DataGrid1.SelectedItem.Cells[2].Text;
            item.UnitPrice = decimal.Parse(DataGrid1.SelectedItem.Cells[3].Text);
            item.Quantity = 1;
            arr.Add(item);
        }

        private void Button1_Click(object sender, System.EventArgs e)
        {
            Response.Redirect("cart.aspx");
        }
    }
}



Reply With Quote