object GetParentFieldValuePostBack(CCSCascadedLookupField field)
        {
            using (new EnterExitLogger("CCSCascadedLookupControl:GetParentFieldValuePostBack function"))
            {
                if (field != null)
                {
                    if (field.LinkToParent)
                    {
                        string ParentColumnId = field.GetParentColumnId();
                        if (!string.IsNullOrEmpty(ParentColumnId))
                        {
                            SPFieldLookup fieldParent = SPContext.Current.List.Fields[new Guid(ParentColumnId)] as SPFieldLookup;

                            if (fieldParent != null)
                            {
                                List<Control> collect = new List<Control>();

                                Utilities.FindControlRecursive(Page, typeof(MultipleLookupField), ref collect);
                                if (collect.Count > 0)
                                {
                                    foreach (Control ctrl in collect)
                                    {
                                        if (((MultipleLookupField)ctrl).FieldName.Equals(fieldParent.InternalName, StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            Utils.LogManager.write("Return Parent Field : " + fieldParent.Title + ", MultipleLookupField Value: " + (((MultipleLookupField)ctrl).Value != null ? ((MultipleLookupField)ctrl).Value : "NULL"));
                                            return ((MultipleLookupField)ctrl).Value;
                                        }
                                    }
                                }

                                collect.Clear();
                                Utilities.FindControlRecursive(Page, typeof(CCSCascadedLookupControl), ref collect);
                                if (collect.Count > 0)
                                {
                                    foreach (Control ctrl in collect)
                                    {
                                        if (((CCSCascadedLookupControl)ctrl).FieldName.Equals(fieldParent.InternalName, StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            Utils.LogManager.write("Return Parent Field : " + fieldParent.Title + ", CCSCascadedLookupControl Value: " + (((CCSCascadedLookupControl)ctrl).Value != null ? ((CCSCascadedLookupControl)ctrl).Value : "NULL"));
                                            return ((CCSCascadedLookupControl)ctrl).Value;
                                        }
                                    }
                                }

                                collect.Clear();
                                Utilities.FindControlRecursive(Page, typeof(LookupField), ref collect);

                                if (collect.Count > 0)
                                {
                                    foreach (Control ctrl in collect)
                                    {
                                        if (((LookupField)ctrl).FieldName.Equals(fieldParent.InternalName, StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            Utils.LogManager.write("Return Parent Field : " + fieldParent.Title + ", LookupField Value: " + (((LookupField)ctrl).Value != null ? ((LookupField)ctrl).Value : "NULL"));
                                            return ((LookupField)ctrl).Value;
                                        }
                                    }
                                }

                            }
                        }
                    }
                }

                Utils.LogManager.write("Return Value: Null");
                return null;
            }
        }
        object GetParentFieldValueStart(CCSCascadedLookupField field)
        {
            using (new EnterExitLogger("CCSCascadedLookupControl:GetParentFieldValueStart function"))
            {
                if (field.LinkToParent)
                {
                    string ParentColumnId = field.GetParentColumnId();
                    if (!string.IsNullOrEmpty(ParentColumnId))
                    {
                        SPFieldLookup fieldParent = SPContext.Current.List.Fields[new Guid(ParentColumnId)] as SPFieldLookup;
                        if (fieldParent.AllowMultipleValues)
                        {
                            Utils.LogManager.write("Parent Field : " + fieldParent.Title + ", Allow Multiple Values: true");
                            SPFieldLookupValueCollection valColl = fieldParent.FieldRenderingControl.ItemFieldValue as SPFieldLookupValueCollection;
                            if (valColl != null && valColl.Count > 0)
                            {
                                Utils.LogManager.write("Return Parent Field : " + fieldParent.Title + ", Value: " + valColl.ToString());
                                return valColl;
                            }

                            string val = fieldParent.FieldRenderingControl.ItemFieldValue as string;

                            if (!string.IsNullOrEmpty(val))
                            {
                                string[] vals = val.Split(new string[] { ";#" }, StringSplitOptions.None);

                                if (vals.Length >= 2)
                                {
                                    valColl = new SPFieldLookupValueCollection();
                                    for (int i = 0; i <= vals.Length - 2; i = i + 2)
                                    {
                                        valColl.Add(new SPFieldLookupValue(int.Parse(vals[i]), vals[i + 1]));
                                    }

                                    Utils.LogManager.write("Return Parent Field : " + fieldParent.Title + ", Value: " + valColl.ToString());
                                    return valColl;
                                }
                            }
                        }
                        else
                        {
                            Utils.LogManager.write("Parent Field : " + fieldParent.Title + ", Allow Multiple Values: false");
                            
                            if (fieldParent.FieldRenderingControl.ItemFieldValue != null)
                            {
                                SPFieldLookupValue lookupVal = fieldParent.FieldRenderingControl.ItemFieldValue as SPFieldLookupValue;

                                if (lookupVal != null)
                                {
                                    Utils.LogManager.write("Return Parent Field : " + fieldParent.Title + ", Value: " + lookupVal.ToString());
                                    return lookupVal;
                                }
                                else
                                {
                                    string val = fieldParent.FieldRenderingControl.ItemFieldValue.ToString();
                                    if (!string.IsNullOrEmpty(val))
                                    {
                                        string[] vals = val.Split(new string[] { ";#" }, StringSplitOptions.None);
                                        if (vals.Length == 2)
                                        {
                                            Utils.LogManager.write("Return Parent Field : " + fieldParent.Title + ", Value: " + vals[0]);
                                            return new SPFieldLookupValue(int.Parse(vals[0]), vals[1]);
                                        }
                                        else if (vals.Length == 1)
                                        {
                                            Utils.LogManager.write("Return Parent Field : " + fieldParent.Title + ", Value: " + vals[0]);
                                            return vals[0];
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                Utils.LogManager.write("Return Value: Null");
                return null;
            }
        }