Exemplo n.º 1
0
        /// <devdoc>
        /// Extracts the value(s) from the given cell and puts the value(s) into a dictionary.  Indicate includeReadOnly
        /// to have readonly fields' values inserted into the dictionary.
        /// </devdoc>
        public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
        {
            DataBoundControlHelper.ExtractValuesFromBindableControls(dictionary, cell);

            IBindableTemplate bindableTemplate = ItemTemplate as IBindableTemplate;

            if (((rowState & DataControlRowState.Alternate) != 0) && (AlternatingItemTemplate != null))
            {
                bindableTemplate = AlternatingItemTemplate as IBindableTemplate;
            }
            if (((rowState & DataControlRowState.Edit) != 0) && EditItemTemplate != null)
            {
                bindableTemplate = EditItemTemplate as IBindableTemplate;
            }
            else if ((rowState & DataControlRowState.Insert) != 0 && InsertVisible)
            {
                if (InsertItemTemplate != null)
                {
                    bindableTemplate = InsertItemTemplate as IBindableTemplate;
                }
                else
                {
                    if (EditItemTemplate != null)
                    {
                        bindableTemplate = EditItemTemplate as IBindableTemplate;
                    }
                }
            }

            if (bindableTemplate != null)
            {
                bool convertEmptyStringToNull = ConvertEmptyStringToNull;
                foreach (DictionaryEntry entry in bindableTemplate.ExtractValues(cell.BindingContainer))
                {
                    object value = entry.Value;
                    if (convertEmptyStringToNull && value is string && ((string)value).Length == 0)
                    {
                        dictionary[entry.Key] = null;
                    }
                    else
                    {
                        dictionary[entry.Key] = value;
                    }
                }
            }
            return;
        }
        public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
        {
            DataBoundControlHelper.ExtractValuesFromBindableControls(dictionary, cell);
            IBindableTemplate itemTemplate = this.ItemTemplate as IBindableTemplate;

            if (((rowState & DataControlRowState.Alternate) != DataControlRowState.Normal) && (this.AlternatingItemTemplate != null))
            {
                itemTemplate = this.AlternatingItemTemplate as IBindableTemplate;
            }
            if (((rowState & DataControlRowState.Edit) != DataControlRowState.Normal) && (this.EditItemTemplate != null))
            {
                itemTemplate = this.EditItemTemplate as IBindableTemplate;
            }
            else if (((rowState & DataControlRowState.Insert) != DataControlRowState.Normal) && this.InsertVisible)
            {
                if (this.InsertItemTemplate != null)
                {
                    itemTemplate = this.InsertItemTemplate as IBindableTemplate;
                }
                else if (this.EditItemTemplate != null)
                {
                    itemTemplate = this.EditItemTemplate as IBindableTemplate;
                }
            }
            if (itemTemplate != null)
            {
                bool convertEmptyStringToNull = this.ConvertEmptyStringToNull;
                foreach (DictionaryEntry entry in itemTemplate.ExtractValues(cell.BindingContainer))
                {
                    object obj2 = entry.Value;
                    if ((convertEmptyStringToNull && (obj2 is string)) && (((string)obj2).Length == 0))
                    {
                        dictionary[entry.Key] = null;
                    }
                    else
                    {
                        dictionary[entry.Key] = obj2;
                    }
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Extrai os valores da linha da instancia.
 /// </summary>
 /// <param name="fieldValues"></param>
 /// <param name="includeKeys"></param>
 protected virtual void ExtractRowValues(IOrderedDictionary fieldValues, bool includeKeys)
 {
     if (fieldValues != null)
     {
         DataBoundControlHelper.ExtractValuesFromBindableControls(fieldValues, this);
         IBindableTemplate itemTemplate = null;
         itemTemplate = this.ItemTemplate as IBindableTemplate;
         string[] dataKeyNamesInternal = this.DataKeyNamesInternal;
         if (itemTemplate != null)
         {
             if ((_dataItemContainer != null) && (itemTemplate != null))
             {
                 foreach (DictionaryEntry entry in itemTemplate.ExtractValues(_dataItemContainer))
                 {
                     if (includeKeys || (Array.IndexOf(dataKeyNamesInternal, entry.Key) == -1))
                     {
                         fieldValues[entry.Key] = entry.Value;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Read the value in the templates and add to dictionary
 /// </summary>
 /// <param name="dictionary"></param>
 /// <param name="cell"></param>
 /// <param name="rowState"></param>
 /// <param name="includeReadOnly"></param>
 public override void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
 {
     if ((rowState & DataControlRowState.Edit) == DataControlRowState.Edit)
     {
         if (this.EditItemTemplate != null)
         {
             IBindableTemplate  templ = (IBindableTemplate)this.EditItemTemplate;
             IOrderedDictionary dict  = templ.ExtractValues(cell);
             foreach (var key in dict.Keys)
             {
                 dictionary.Add(key, dict[key]);
             }
         }
     }
     else if ((rowState & DataControlRowState.Insert) == DataControlRowState.Insert)
     {
         IBindableTemplate templ = (IBindableTemplate)(this.InsertItemTemplate ?? this.EditItemTemplate);
         if (templ != null)
         {
             IOrderedDictionary dict = templ.ExtractValues(cell);
             foreach (var key in dict.Keys)
             {
                 dictionary.Add(key, dict[key]);
             }
         }
     }
     else if (cell.HasControls())
     {
         // We will not have controls during deleting
         GridViewRow row = (GridViewRow)cell.NamingContainer;
         Label       lbl = (Label)cell.Controls[0];
         _extractedValue        = new Pair();
         _extractedValue.First  = row.RowIndex;
         _extractedValue.Second = lbl.Text;
     }
     base.ExtractValuesFromCell(dictionary, cell, rowState, includeReadOnly);
 }