View Code for Web/Majors/Edit.aspx.cs

Source code for the file Web/Majors/Edit.aspx.cs is shown below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.WebControls;
using QuantumConcepts.CodeGenerator.Sample.DataAccess;
using QuantumConcepts.CodeGenerator.Sample.Logic;
using QuantumConcepts.CodeGenerator.Sample.Web.WebControls;
using QuantumConcepts.CommonWeb.WebControls;

namespace QuantumConcepts.CodeGenerator.Sample.Web.Majors
{
	public partial class Edit : BasePage
	{
        protected EditMajor EditControl;
			
        private Major Major { get; set; }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

			string idString = this.Request.QueryString["ID"];
            int id;
            
            if (int.TryParse(idString, out id))
            {
            	this.Major = MajorLogic.GetByID(this.DataContext, id);

            	if (!this.IsPostBack)
                	this.EditControl.DataBind(this.Major);
			}
        }

        protected void EditControl_Saved(object sender, Major obj)
        {
            this.Response.Redirect("Default.aspx");
        }

        protected void EditControl_Cancelled(object sender, EventArgs e)
        {
            this.Response.Redirect("Default.aspx");
        }
	}
}