protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { populateDDlEmployeeIDOnpageLoad(); loadgrdShowSelectedappointmentOnPageLoad(); } } #region Load ddlEmployeeID On page Load public void populateDDlEmployeeIDOnpageLoad() { ArrayList staffList = new ArrayList(); systemBusinessLayer = new BusinessLayer(); staffList = systemBusinessLayer.loadEmployeesWithAppointments(date); ddlEmployeeID.DataSource = staffList; ddlEmployeeID.DataTextField = "EmployeeName1"; ddlEmployeeID.DataValueField = "EmpRecNumber1"; ddlEmployeeID.DataBind(); ddlEmployeeID.Items.Insert(0, ".:Select Employee:."); } #endregion #region A method to Load grdShowSelectedappointment On Page Load with all appoinments protected void loadgrdShowSelectedappointmentOnPageLoad() { string date = DateTime.Now.ToShortDateString(); DataTable dt = new DataTable(); systemBusinessLayer = new BusinessLayer(); // dt = systemBusinessLayer.grdLoadSpecificEmployeeOnPageLoad(date); dt = systemBusinessLayer.GetAllAppointments(date); grdShowSelectedappointment.DataSource = dt; grdShowSelectedappointment.DataBind(); } #endregion
public void getEmployeeID() { dTable = new DataTable(); systemBusinessLayer = new BusinessLayer(); dTable = systemBusinessLayer.GetAllEmployeesInfo(); foreach (DataRow dRow in dTable.Rows)//Go through each row inside datatable { string fullname = dRow["Fullname"].ToString(); if (ddlEmployeeID.SelectedItem.Text == fullname) { Session["EmpRecNumber"] = dRow["EmpRecNumber"].ToString(); } } } protected void ddlEmployeeID_SelectedIndexChanged(object sender, EventArgs e) { getEmployeeID(); if (DatePicker.SelectedDate.ToShortDateString() == "1/1/0001")//if date is not selected { if (!Page.IsPostBack) { MessageBox.Show(Session["EmpRecNumber"].ToString()); } } else { MessageBox.Show("Invalid selection"); } }
AutoPostBack="True"
Autopostback="false"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)