private void BindDevice() { DropDownListDevice.DataSource = Device.GetDeviceList(Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).CompanyId); DropDownListDevice.DataTextField = "FormattedDevice"; DropDownListDevice.DataValueField = "DeviceId"; DropDownListDevice.DataBind(); DropDownListDevice.Items.Insert(0, new ListItem("Please select", "0")); }
protected void Page_Load(object sender, EventArgs e) { this.employeeDeviceId = Common.GetEncryptedQueryStringValue("employeeDeviceId", 0); this.employeeId = Common.GetEncryptedQueryStringValue("employeeId", 0); this.deviceId = Common.GetEncryptedQueryStringValue("deviceId", 0); ViewState["employeeVehicleId"] = Common.GetEncryptedQueryStringValue("employeeVehicleId", 0); LabelPageTitle.Text = String.Format("{0} {1}", "Employee Device", Employee.GetEmployeeByEmployeeId(this.employeeId).FormattedNameNumber); PanelError.Visible = false; Page.Form.DefaultFocus = DropDownListDevice.ClientID; Page.Form.DefaultButton = ButtonSave.UniqueID; if (this.employeeId != 0) { BindGridviewResult(); } if (!IsPostBack) { DropDownListDevice.Focus(); BindDevice(); if (this.employeeDeviceId != 0) { BindEmployeeDevice(); } if (this.deviceId != 0) { DropDownListDevice.Items.FindByValue(this.deviceId.ToString()).Selected = true; } if (ViewState["employeeId"] != null) { this.employeeId = Convert.ToInt32(ViewState["employeeId"].ToString()); } } }