本文整理匯總了C#中System.Web.UI.Control.DataBind方法的典型用法代碼示例。如果您正苦於以下問題:C# Control.DataBind方法的具體用法?C# Control.DataBind怎麽用?C# Control.DataBind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Web.UI.Control
的用法示例。
在下文中一共展示了Control.DataBind方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnPreRender
protected override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
// Dummy control to which we parent all the data item controls
Control containerControl = new Control();
IEnumerable dataItems = ViewData.Eval(Name) as IEnumerable;
bool hasData = false;
if (dataItems != null) {
int index = 0;
foreach (object dataItem in dataItems) {
hasData = true;
RepeaterItem repeaterItem = new RepeaterItem(index, dataItem) {
ViewData = new ViewDataDictionary(dataItem),
};
ItemTemplate.InstantiateIn(repeaterItem);
containerControl.Controls.Add(repeaterItem);
index++;
}
}
if (!hasData) {
// If there was no data, instantiate the EmptyDataTemplate
Control emptyDataContainer = new Control();
EmptyDataTemplate.InstantiateIn(emptyDataContainer);
containerControl.Controls.Add(emptyDataContainer);
}
Controls.Add(containerControl);
containerControl.DataBind();
}
示例2: DataBindLayoutTemplate
public static void DataBindLayoutTemplate(ListView listView)
{
listView.ThrowIfNull(() => new ArgumentNullException("listView"));
// Create a databound layout template.
var template = new Control();
listView.LayoutTemplate.InstantiateIn(template);
template.DataBind();
// Remove the existing, non-databound layout template.
listView.Controls.RemoveAt(0);
// Add the databound layout template.
listView.Controls.Add(template);
}
示例3: Modify
/// <summary>Applies editor modifications after creating the control.</summary>
/// <param name="editor">The editor to modify.</param>
public virtual void Modify(Control editor)
{
if (this.DataBind)
editor.DataBind();
if (this.Focus)
editor.Focus();
}
示例4: DataBind
/// <summary>
/// Binds all data to the control
/// </summary>
/// <param name="c">Control</param>
public void DataBind(Control c)
{
if (c is MultiView)
{
MultiView mv = (MultiView)c;
foreach (View v in mv.Views)
{
ActionControl(v.ID, ControlActionType.Hide);
}
ActionControl(mv.Views[mv.ActiveViewIndex].ID, ControlActionType.Show);
}
else
{
_bindedControls.Add(c);
c.DataBind();
}
}
示例5: InstantiateIn
public void InstantiateIn(Control container)
{
var names = Set.Split('|');
int i = 0, n;
foreach (var name in names) {
if (name == "*") {
while (i < TemplateControls.Count) Add(container, TemplateControls[i++]);
} else if (int.TryParse(name, out n)) {
while (i < TemplateControls.Count && n > 0) Add(container, TemplateControls[i++]);
} else {
var icon = Icons.New(name);
if (icon != null) {
if (!string.IsNullOrEmpty(CommandArgument)) icon.CommandArgument = CommandArgument;
Add(container, icon);
}
}
}
instantiatedContainer = container;
container.DataBind();
}
示例6: Methods_Deny_Unrestricted
public void Methods_Deny_Unrestricted ()
{
Control c = new Control ();
c.DataBind ();
Assert.IsNull (c.FindControl ("mono"), "FindControl");
Assert.IsFalse (c.HasControls (), "HasControls");
c.RenderControl (writer);
Assert.IsNotNull (c.ResolveUrl (String.Empty), "ResolveUrl");
c.SetRenderMethodDelegate (new RenderMethod (SetRenderMethodDelegate));
#if NET_2_0
c.ApplyStyleSheetSkin (page);
Assert.IsNotNull (c.ResolveClientUrl (String.Empty), "ResolveClientUrl");
#endif
c.Dispose ();
}
示例7: CreateChildControls
protected override void CreateChildControls()
{
Controls.Clear();
if( StatusNameTemplate != null )
{
String dispName = OrderLineStatusUtil.DisplayName(Status);
var statusNameContainer = new OrderLineStatusNameContainer(
OrderLineId,
dispName );
StatusNameTemplate.InstantiateIn( statusNameContainer );
Controls.Add( statusNameContainer );
statusNameContainer.DataBind();
}
if( ReactionInfoTemplate != null && ClientReaction.HasValue )
{
var reaction = (OrderLineChangeReaction)ClientReaction.Value == OrderLineChangeReaction.Accept ?
( !string.IsNullOrEmpty( DisplayAccept ) ? DisplayAccept : OrderLineChangeReaction.Accept.ToTextOrName() ) :
( !string.IsNullOrEmpty( DisplayDecline ) ? DisplayDecline : OrderLineChangeReaction.Decline.ToTextOrName() );
var reactionInfoContainer = new ReactionInfoContainer( reaction, ClientReactionTime.Value );
ReactionInfoTemplate.InstantiateIn( reactionInfoContainer );
Controls.Add( reactionInfoContainer );
reactionInfoContainer.DataBind();
}
//Показываем кнопки только для клиента
if( ReactionCommandsTemplate != null && ClientReactionPending && SiteContext.Current.User.Role == SecurityRole.Client )
{
var container = new Control();
ReactionCommandsTemplate.InstantiateIn( container );
Controls.Add( container );
container.DataBind();
}
}