protected void Page_Load(object sender, EventArgs e) { if (!Authentication.HasResource(User.Identity.Name, "AgentData")) { Response.Redirect(@"/account/logon.aspx?ReturnUrl=%2f"); } if (!IsPostBack) { _agentRepo = RepositoryFactory.CreateAgentRepo(); _rootRepo = RepositoryFactory.CreateRootRepo(); //從QueryString取得 部門代碼 string sn = String.IsNullOrEmpty(Request["sn"]) ? String.Empty : Request["sn"].ToString(); //將員工資料 與下拉式選單綁定 ViewUtils.SetOptions(EmployeeID_FK, _rootRepo.GetEmployee()); PageTitle.Value = "代理簽核資料 > 新增"; if (!String.IsNullOrWhiteSpace(sn)) { //將 viewModel 的值綁定到 頁面上 WebUtils.PageDataBind(_agentRepo.GetAgentData(sn), this.Page); EmployeeName.Value = EmployeeID_FK.Text; PageTitle.Value = "代理簽核資料 > 編輯"; } } }