Ejemplo n.º 1
0
 /// <summary>
 /// Fills the specified <see cref="T:System.Collections.IDictionary"></see> object with the values from the specified <see cref="T:System.Web.UI.WebControls.TableCell"></see> object.
 /// </summary>
 /// <param name="dictionary">A <see cref="T:System.Collections.IDictionary"></see> used to store the values of the specified cell.</param>
 /// <param name="cell">The <see cref="T:System.Web.UI.WebControls.TableCell"></see> that contains the values to retrieve.</param>
 /// <param name="rowState">One of the <see cref="T:System.Web.UI.WebControls.DataControlRowState"></see> values.</param>
 /// <param name="includeReadOnly">true to include the values of read-only fields; otherwise, false.</param>
 public override void ExtractValuesFromCell(System.Collections.Specialized.IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
 {
     if (cell.HasControls() &&
         cell.Controls[0] is EntityDropDownList)
     {
         EntityDropDownList eddl = (EntityDropDownList)cell.Controls[0];
         dictionary[this.DataField] = String.IsNullOrEmpty(eddl.SelectedValue) ? null : eddl.SelectedValue;
     }
 }
Ejemplo n.º 2
0
 public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
 {
     base.InitializeCell(cell, cellType, rowState, rowIndex);
     if (cellType == DataControlCellType.DataCell)
     {
         cell.CssClass = "ms-vb-title";
         CPMenu child = new CPMenu
         {
             UseMaximumWidth = this.UseMaximumWidth,
             MenuFormat      = this.MenuFormat
         };
         if (!string.IsNullOrEmpty(this.MenuTemplateId))
         {
             child.TemplateId = this.MenuTemplateId;
         }
         if (!string.IsNullOrEmpty(this.TextCssClass))
         {
             child.TextCssClass = this.TextCssClass;
         }
         if (!string.IsNullOrEmpty(this.ImageUrlFormat) && string.IsNullOrEmpty(this.ImageUrlFields))
         {
             child.ImageUrl = this.ImageUrlFormat;
         }
         if (!string.IsNullOrEmpty(this.NavigateUrlFormat) && string.IsNullOrEmpty(this.NavigateUrlFields))
         {
             child.NavigateUrl = this.NavigateUrlFormat;
         }
         if (!string.IsNullOrEmpty(this.TextFormat) && string.IsNullOrEmpty(this.TextFields))
         {
             child.Text = this.TextFormat;
         }
         if (!string.IsNullOrEmpty(this.ToolTipFormat) && string.IsNullOrEmpty(this.ToolTipFields))
         {
             child.ToolTip = this.ToolTipFormat;
         }
         if (cell.HasControls())
         {
             // replace Microsoft.SharePoint.WebControls.Menu that was added by base method
             cell.Controls.Clear();
         }
         cell.Controls.Add(child);
         if (((rowState & DataControlRowState.Insert) == DataControlRowState.Normal) && ((!string.IsNullOrEmpty(this.TextFields) || !string.IsNullOrEmpty(this.ImageUrlFields)) || ((!string.IsNullOrEmpty(this.ToolTipFields) || !string.IsNullOrEmpty(this.NavigateUrlFields)) || !string.IsNullOrEmpty(this.TokenNameAndValueFields))))
         {
             // set DataBinding event handler to execute the handler for Microsoft.SharePoint.WebControls.Menu
             child.DataBinding += new EventHandler(delegate(object sender, EventArgs e)
             {
                 Type baseType = typeof(SPMenuField);
                 baseType.InvokeMember("DataBindingEventHandler", BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, this, new[] { sender, e });
             });
         }
     }
 }
Ejemplo n.º 3
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);
 }