Ejemplo n.º 1
0
        public void SetDataSource(object[] attributes)
        {
            try
            {
                if (attributes.Length == 0)
                {
                    return;
                }
                ReferenceMappingAttribute attribute = attributes[0] as ReferenceMappingAttribute;
                if (attribute == null)
                {
                    return;
                }

                IGenericEntity referencedEntity  = EntityFactory.GetEntityInstance(attribute.ReferencedEntity, SessionManager.GetSessionValueNoRedirect((IndBasePage)this.Page, SessionStrings.CONNECTION_MANAGER));
                DataRow        referencedDataRow = referencedEntity.SelectNew();
                this.SetValue(referencedDataRow["Rank"]);
            }
            catch (IndException ex)
            {
                ControlHierarchyManager.ReportError(ex);
                return;
            }
            catch (Exception ex)
            {
                ControlHierarchyManager.ReportError(new IndException(ex));
                return;
            }
        }
        public void SetDataSource(object[] attributes)
        {
            try
            {
                ReferenceMappingAttribute attribute = attributes[0] as ReferenceMappingAttribute;
                if (attribute == null)
                {
                    throw new IndException(ApplicationMessages.EXCEPTION_WRONG_ATTRIBUTE_RECEIVED);
                }


                IGenericEntity referencedEntity = EntityFactory.GetEntityInstance(attribute.ReferencedEntity, SessionManager.GetSessionValueNoRedirect((IndBasePage)this.Page, SessionStrings.CONNECTION_MANAGER));
                //Call the GetAll() method of the referenced object
                DataSet referencedDataSet = referencedEntity.GetAll();
                DSUtils.AddEmptyRecord(referencedDataSet.Tables[0]);
                //Set the DataSource, DataMember, DataValueField and DataTextField of the combobox
                this.DataSource = referencedDataSet;
                this.DataMember = referencedDataSet.Tables[0].TableName;
                this.DataBind();
                this.SelectedValue = ApplicationConstants.INT_NULL_VALUE.ToString();
            }
            catch (IndException ex)
            {
                ControlHierarchyManager.ReportError(ex);
                return;
            }
            catch (Exception ex)
            {
                ControlHierarchyManager.ReportError(new IndException(ex));
                return;
            }
        }