C# Class + constructors + calling the class RRS feed

  • Question

  • I am struggling to put all the pieces together.  I believe I can create a class, put together the constructors and have put a db file in the APP_DATA folder to access the file. 

    What I am able to do is access the db file to display information for a customer during the load, but what I can't figure out is how to create an object that contains the information for a selected customer.

    How do I call the class to display the customer?

    Here is my class:

    public class Customer
            public int CustomerID;
            public string Name;
            public string Street;
            public string City;
            public string State;
            public string ZipCode;
            public string Phone;
            public string Email;

            public Customer()
                //default ctor

            public Customer (int cid, string n, string s, string c, string st, string z, string ph, string e)
                this.CustomerID = cid;
                this.Name = n;
                this.Street = s;
                this.City = c;
                this.State = st;
                this.ZipCode = z;
                this.Phone = ph;
                this.Email = e;


    Here is my code which displays the customer info when the customer is selected from a drop down list, but this only happens during the load, I can't figure out how to call the class to have the same information displayed. 

    public partial class CustomerDisplay : System.Web.UI.Page
            protected void Page_Load(object sender, EventArgs e)
                if (!IsPostBack)
                DataView customerTable = (DataView)AccessDataSource1.Select(DataSourceSelectArguments.Empty);

                customerTable.RowFilter = "CustomerID = '" + ddlCustomer.SelectedValue + "'";

                DataRowView row = customerTable[0];

                lblStreetAddress.Text = row["Address"].ToString();
                lblCityStateZip.Text = (row["City"] + ", " + row["State"] + " " + row["ZipCode"]).ToString();
                lblPhone.Text = row["Phone"].ToString();
                lblEmail.Text = row["Email"].ToString();


    I feel like I am both close and miles away.

    Thank you for any assistance you can provide.

    • Moved by Dave PatrickMVP Monday, February 5, 2018 1:48 PM
    • Moved by CoolDadTx Monday, February 5, 2018 3:50 PM ASP.NET related
    Monday, February 5, 2018 8:13 AM

All replies

    • Moved by Dave Patrick MVP 1 hour 16 minutes ago

    What does this mean?  Moved where and why?

    Monday, February 5, 2018 3:06 PM
  • Questions related to ASP.NET should be posted in the ASP.NET forums. Your question is related to how postbacks and UI control events work in ASP.NET so it is best asked over there.

    Michael Taylor http://www.michaeltaylorp3.net

    Monday, February 5, 2018 3:49 PM
  • OK, I thought since I was asking about accessing the class and the underlying C# code associated with the class, it should have been posted here.
    Monday, February 5, 2018 6:47 PM
  • I missed that it was asp.net Better to ask in microsoft official asp.net forums over here.




    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Monday, February 5, 2018 7:23 PM