As you can probably tell by the basic question to follow, I havn't done much web stuff.
I have a basic web form for making a request. All I need to do is add a record to a table and do not need to retrieve any data or show any data. Just add a single record. Here is what I did unsuccessfully.
protected Contact oContact;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.oContact = (Contact)this.RegisterPrimaryBizObj(new Contact());
this.oContact.NewEntity();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
// Save the data to an access table for review by sales department.
this.oContact.Entity.Request_Date = DateTime.Now;
this.oContact.Entity.Contact_via = this.lstOwnProperty.SelectedValue;
if (this.lstOwnProperty.SelectedValue == "Yes")
this.oContact.Entity.Own_Land = true;
else
this.oContact.Entity.Own_Land = false;
this.oContact.SaveEntity();
// Redirect
Response.Redirect("InfoRequestSubmitted.aspx");
}
All the rest of the fields are bound controls. I am getting a null exception on the oContact object in the submit click event. It seems the object creation in the load event is not persistent. What is the proper way to do this? I could create it in the click event but then would just unbind all the controls and set them in the click event also.
Any suggestions are appreciated. I will get the hang of this web stuff soon.
Tim
Timothy Bryan