private void BindData() { DataSet devices = new DataSet(); devices = _deviceDAO.GetDevices(); deviceGrid.DataSource = devices.Tables["mds_device"]; }
protected void deviceGrid_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode) { GridEditableItem editedItem = e.Item as GridEditableItem; //get all device types DataSet dropdownSource = new DataSet(); SNumCodeDAO sNumCodeDAO = new SNumCodeDAO(); dropdownSource = sNumCodeDAO .GetCodesByType(SNumcodeType.MDS_DEVICE_TYPE.ToString()); RadComboBox deviceType = (RadComboBox)editedItem .FindControl("device_type_RadComboBox"); RadComboBox deviceName = (RadComboBox)editedItem.FindControl("rcbName"); if (e.Item.ItemIndex < 0) { DeviceDAO devDAO = new DeviceDAO(); DataTable dtTemp = devDAO.GetDevices().Tables[0].Select("device_type <> 'CT'").CopyToDataTable(); deviceName.DataTextField = "device_name"; deviceName.DataValueField = "device_name"; deviceName.DataSource = dtTemp; deviceName.DataBind(); } deviceType .DataSource = dropdownSource .Tables[SNumcodeType.MDS_DEVICE_TYPE.ToString()]; deviceType.DataTextField = "char_short_translation"; deviceType.DataValueField = "code"; deviceType.DataBind(); deviceType.Items.Insert(0, new RadComboBoxItem("", "0")); //workstations WorkstationDAO deviceDAO = new PackstationDAO(); dropdownSource = deviceDAO.GetWorkstations(); RadComboBox workstationLabel = (RadComboBox)editedItem .FindControl("workstation_label_RadComboBox"); RequiredFieldValidator RequiredFieldValidator2 = (RequiredFieldValidator)editedItem .FindControl("RequiredFieldValidator2"); workstationLabel.DataSource = dropdownSource.Tables["mds_workstation"]; workstationLabel.DataTextField = "workstation_label"; workstationLabel.DataValueField = "workstation_id"; workstationLabel.DataBind(); workstationLabel.Items.Insert(0, new RadComboBoxItem("", "0")); //users //UserDAO userDAO = new UserDAO(); //dropdownSource = userDAO.GetUsers(); //RadComboBox username = (RadComboBox)editedItem // .FindControl("username_RadComboBox"); //username.DataSource = dropdownSource.Tables["tblusers"]; //username.DataTextField = "displayname"; //username.DataValueField = "userid"; //username.DataBind(); //username.Items.Insert(0, new RadComboBoxItem("", "0")); //Register script for status validation CreateStatusValidationScript(deviceType.ClientID, workstationLabel.ClientID); _device = null; if (e.Item.ItemIndex != -1) { int deviceID = int.Parse( editedItem .OwnerTableView .DataKeyValues[e.Item.ItemIndex]["device_id"] .ToString()); _deviceDAO = new DeviceDAO(); _device = _deviceDAO.GetDeviceByID(deviceID); deviceType.SelectedValue = _device.Type.ToString(); workstationLabel.SelectedValue = _device.WorkstationId.ToString(); //username.SelectedValue = _device.CurrentUser.ToString(); } } }