本文整理汇总了C#中Rock.Web.UI.Controls.RockDropDownList.DataBind方法的典型用法代码示例。如果您正苦于以下问题:C# RockDropDownList.DataBind方法的具体用法?C# RockDropDownList.DataBind怎么用?C# RockDropDownList.DataBind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Web.UI.Controls.RockDropDownList
的用法示例。
在下文中一共展示了RockDropDownList.DataBind方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigurationControls
/// <summary>
/// Creates the HTML controls required to configure this type of field
/// </summary>
/// <returns></returns>
public override List<Control> ConfigurationControls()
{
var controls = base.ConfigurationControls();
var tbValuePrompt = new RockTextBox();
controls.Add( tbValuePrompt );
tbValuePrompt.AutoPostBack = true;
tbValuePrompt.TextChanged += OnQualifierUpdated;
tbValuePrompt.Label = "Label Prompt";
tbValuePrompt.Help = "The text to display as a prompt in the label textbox.";
var ddl = new RockDropDownList();
controls.Add( ddl );
ddl.AutoPostBack = true;
ddl.SelectedIndexChanged += OnQualifierUpdated;
ddl.DataTextField = "Name";
ddl.DataValueField = "Id";
ddl.DataSource = new Rock.Model.DefinedTypeService( new RockContext() ).Queryable().OrderBy( d => d.Order ).ToList();
ddl.DataBind();
ddl.Items.Insert(0, new ListItem(string.Empty, string.Empty));
ddl.Label = "Defined Type";
ddl.Help = "Optional Defined Type to select values from, otherwise values will be free-form text fields.";
var tbCustomValues = new RockTextBox();
controls.Add( tbCustomValues );
tbCustomValues.TextMode = TextBoxMode.MultiLine;
tbCustomValues.Rows = 3;
tbCustomValues.AutoPostBack = true;
tbCustomValues.TextChanged += OnQualifierUpdated;
tbCustomValues.Label = "Custom Values";
tbCustomValues.Help = "Optional list of options to use for the values. Format is either 'value1,value2,value3,...', or 'value1:text1,value2:text2,value3:text3,...'.";
return controls;
}
示例2: ConfigurationControls
/// <summary>
/// Creates the HTML controls required to configure this type of field
/// </summary>
/// <returns></returns>
public override List<Control> ConfigurationControls()
{
var controls = base.ConfigurationControls();
var ddl = new RockDropDownList();
controls.Add( ddl );
ddl.AutoPostBack = true;
ddl.SelectedIndexChanged += OnQualifierUpdated;
ddl.DataTextField = "Name";
ddl.DataValueField = "Id";
ddl.DataSource = new Rock.Model.DefinedTypeService().Queryable().OrderBy( d => d.Order ).ToList();
ddl.DataBind();
ddl.Items.Insert(0, new ListItem(string.Empty, string.Empty));
ddl.Label = "Defined Type";
ddl.Help = "Optional Defined Type to select values from, otherwise values will be free-form text fields.";
return controls;
}
示例3: CreateChildControls
/// <summary>
/// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
/// </summary>
protected override void CreateChildControls()
{
Controls.Clear();
_hfFormGuid = new HiddenField();
_hfFormGuid.ID = this.ID + "_hfFormGuid";
Controls.Add( _hfFormGuid );
_ddlNotificationSystemEmail = new RockDropDownList();
_ddlNotificationSystemEmail.DataValueField = "Id";
_ddlNotificationSystemEmail.DataTextField = "Title";
_ddlNotificationSystemEmail.Label = "Notification Email";
_ddlNotificationSystemEmail.Help = "An optional system email that should be sent to the person or people assigned to this activity (Any System Email with a category of 'Workflow').";
_ddlNotificationSystemEmail.ID = this.ID + "_ddlNotificationSystemEmail";
Controls.Add( _ddlNotificationSystemEmail );
_ddlNotificationSystemEmail.DataSource = new SystemEmailService( new RockContext() ).Queryable()
.Where( e => e.Category == "Workflow" ).OrderBy( e => e.Title ).ToList();
_ddlNotificationSystemEmail.DataBind();
_ddlNotificationSystemEmail.Items.Insert( 0, new ListItem( "None", "0" ) );
_cbIncludeActions = new RockCheckBox();
_cbIncludeActions.Label = "Include Actions in Email";
_cbIncludeActions.Text = "Yes";
_cbIncludeActions.Help = "Should the email include the option for recipient to select an action directly from within the email? Note: This only applies if none of the the form fields are required.";
_cbIncludeActions.ID = this.ID + "_cbIncludeActions";
Controls.Add( _cbIncludeActions );
_ceHeaderText = new CodeEditor();
_ceHeaderText.Label = "Form Header";
_ceHeaderText.Help = "Text to display to user above the form fields. <span class='tip tip-liquid'></span> <span class='tip tip-html'>";
_ceHeaderText.ID = this.ID + "_tbHeaderText";
_ceHeaderText.EditorMode = CodeEditorMode.Html;
_ceHeaderText.EditorTheme = CodeEditorTheme.Rock;
_ceHeaderText.EditorHeight = "200";
Controls.Add( _ceHeaderText );
_ceFooterText = new CodeEditor();
_ceFooterText.Label = "Form Footer";
_ceFooterText.Help = "Text to display to user below the form fields. <span class='tip tip-liquid'></span> <span class='tip tip-html'>";
_ceFooterText.ID = this.ID + "_tbFooterText";
_ceFooterText.EditorMode = CodeEditorMode.Html;
_ceFooterText.EditorTheme = CodeEditorTheme.Rock;
_ceFooterText.EditorHeight = "200";
Controls.Add( _ceFooterText );
_falActions = new WorkflowFormActionList();
_falActions.ID = this.ID + "_falActions";
Controls.Add( _falActions );
_ddlActionAttribute = new RockDropDownList();
_ddlActionAttribute.ID = this.ID + "_ddlActionAttribute";
_ddlActionAttribute.Label = "Command Selected Attribute";
_ddlActionAttribute.Help = "Optional text attribute that should be updated with the selected command label.";
Controls.Add( _ddlActionAttribute );
}
示例4: CreateChildControls
/// <summary>
/// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
/// </summary>
protected override void CreateChildControls()
{
if ( !_controlsLoaded )
{
Controls.Clear();
_hfExistingKeyNames = new HtmlInputHidden();
_hfExistingKeyNames.AddCssClass( "js-existing-key-names" );
_hfExistingKeyNames.ID = this.ID + "_hfExistingKeyNames";
Controls.Add( _hfExistingKeyNames );
_lAttributeActionTitle = new Literal();
_lAttributeActionTitle.ID = "lAttributeActionTitle";
Controls.Add( _lAttributeActionTitle );
_validationSummary = new ValidationSummary();
_validationSummary.ID = "valiationSummary";
_validationSummary.CssClass = "alert alert-danger";
_validationSummary.HeaderText = "Please Correct the Following";
Controls.Add( _validationSummary );
_tbName = new RockTextBox();
_tbName.ID = "tbName";
_tbName.Label = "Name";
_tbName.Required = true;
Controls.Add( _tbName );
_tbDescription = new RockTextBox();
_tbDescription.Label = "Description";
_tbDescription.ID = "tbDescription";
_tbDescription.TextMode = TextBoxMode.MultiLine;
_tbDescription.Rows = 3;
Controls.Add( _tbDescription );
_cpCategories = new CategoryPicker();
_cpCategories.ID = "cpCategories_" + this.ID.ToString();
_cpCategories.Label = "Categories";
_cpCategories.AllowMultiSelect = true;
_cpCategories.EntityTypeId = EntityTypeCache.Read( typeof( Rock.Model.Attribute ) ).Id;
_cpCategories.EntityTypeQualifierColumn = "EntityTypeId";
Controls.Add( _cpCategories );
_tbKey = new RockTextBox();
_tbKey.ID = "tbKey";
_tbKey.Label = "Key";
_tbKey.Required = true;
Controls.Add( _tbKey );
_cvKey = new CustomValidator();
_cvKey.ID = "cvKey";
_cvKey.ControlToValidate = _tbKey.ID;
_cvKey.ClientValidationFunction = "validateKey";
_cvKey.ServerValidate += cvKey_ServerValidate;
_cvKey.Display = ValidatorDisplay.Dynamic;
_cvKey.CssClass = "validation-error help-inline";
_cvKey.ErrorMessage = "There is already an existing property with the key value you entered. Please select a different key value.";
Controls.Add( _cvKey );
_tbIconCssClass = new RockTextBox();
_tbIconCssClass.ID = "_tbIconCssClass";
_tbIconCssClass.Label = "Icon CSS Class";
Controls.Add( _tbIconCssClass );
_cbRequired = new RockCheckBox();
_cbRequired.ID ="cbRequired";
_cbRequired.Label = "Required";
_cbRequired.Text = "Require a value";
Controls.Add( _cbRequired );
_cbShowInGrid = new RockCheckBox();
_cbShowInGrid.ID = "cbShowInGrid";
_cbShowInGrid.Label = "Show in Grid";
_cbShowInGrid.Text = "Yes";
_cbShowInGrid.Help = "If selected, this attribute will be included in a grid.";
Controls.Add( _cbShowInGrid );
_ddlFieldType = new RockDropDownList();
_ddlFieldType.ID = "ddlFieldType";
_ddlFieldType.Label = "Field Type";
_ddlFieldType.AutoPostBack = true;
_ddlFieldType.SelectedIndexChanged += _ddlFieldType_SelectedIndexChanged;
Controls.Add( _ddlFieldType );
if ( !Page.IsPostBack )
{
_ddlFieldType.DataValueField = "Id";
_ddlFieldType.DataTextField = "Name";
_ddlFieldType.DataSource = FieldTypeCache.All();
_ddlFieldType.DataBind();
}
_phQualifiers = new PlaceHolder();
_phQualifiers.ID = "phQualifiers";
_phQualifiers.EnableViewState = false;
Controls.Add( _phQualifiers );
_phDefaultValue = new PlaceHolder();
//.........这里部分代码省略.........
示例5: ConfigurationControls
/// <summary>
/// Creates the HTML controls required to configure this type of field
/// </summary>
/// <returns></returns>
public override List<Control> ConfigurationControls()
{
var controls = base.ConfigurationControls();
var ddl = new RockDropDownList();
controls.Add( ddl );
ddl.AutoPostBack = true;
ddl.SelectedIndexChanged += OnQualifierUpdated;
ddl.DataTextField = "Name";
ddl.DataValueField = "Id";
ddl.DataSource = new BinaryFileTypeService( new RockContext() )
.Queryable()
.OrderBy( f => f.Name )
.Select( f => new { f.Id, f.Name } )
.ToList();
ddl.DataBind();
ddl.Items.Insert( 0, new ListItem( string.Empty, string.Empty ) );
ddl.Label = "File Type";
ddl.Help = "The type of files to list.";
return controls;
}
示例6: CreateChildControls
/// <summary>
/// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
/// </summary>
protected override void CreateChildControls()
{
Controls.Clear();
_hfValue.ID = this.ID + "_hfValue";
Controls.Add( _hfValue );
_actionControls = new List<RockTextBox>();
_buttonHtmlControls = new List<RockDropDownList>();
_activityControls = new List<RockDropDownList>();
_responseControls = new List<RockTextBox>();
string[] nameValues = this.Value.Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries );
for ( int i = 0; i < nameValues.Length; i++ )
{
string[] nameValueResponse = nameValues[i].Split( new char[] { '^' } );
var tbAction = new RockTextBox();
tbAction.ID = this.ID + "_tbAction" + i.ToString();
Controls.Add( tbAction );
tbAction.Placeholder = "Action";
tbAction.AddCssClass( "form-action-key" );
tbAction.AddCssClass( "form-control" );
tbAction.AddCssClass( "js-form-action-input" );
tbAction.Text = nameValueResponse.Length > 0 ? nameValueResponse[0] : string.Empty;
_actionControls.Add( tbAction );
var ddlButtonHtml = new RockDropDownList();
ddlButtonHtml.ID = this.ID + "_ddlButtonHtml" + i.ToString();
Controls.Add( ddlButtonHtml );
ddlButtonHtml.AddCssClass( "form-action-button" );
ddlButtonHtml.AddCssClass( "form-control" );
ddlButtonHtml.AddCssClass( "js-form-action-input" );
var definedType = Rock.Web.Cache.DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.BUTTON_HTML.AsGuid() );
foreach( var definedValue in definedType.DefinedValues )
{
var li = new ListItem( definedValue.Value, definedValue.Guid.ToString() );
li.Selected = nameValueResponse.Length > 1 && li.Value.Equals( nameValueResponse[1], StringComparison.OrdinalIgnoreCase );
ddlButtonHtml.Items.Add( li );
}
_buttonHtmlControls.Add( ddlButtonHtml );
var ddlActivity = new RockDropDownList();
ddlActivity.ID = this.ID + "_ddlActivity" + i.ToString();
Controls.Add( ddlActivity );
ddlActivity.AddCssClass( "form-action-value" );
ddlActivity.AddCssClass( "form-control" );
ddlActivity.AddCssClass( "js-form-action-input" );
ddlActivity.DataTextField = "Value";
ddlActivity.DataValueField = "Key";
ddlActivity.DataSource = Activities;
ddlActivity.DataBind();
ddlActivity.Items.Insert( 0, new ListItem( string.Empty, string.Empty ) );
foreach(ListItem li in ddlActivity.Items)
{
li.Selected = nameValueResponse.Length > 2 && li.Value.Equals( nameValueResponse[2], StringComparison.OrdinalIgnoreCase );
}
_activityControls.Add( ddlActivity );
var tbResponse = new RockTextBox();
tbResponse.ID = this.ID + "_tbResponse" + i.ToString();
Controls.Add( tbResponse );
tbResponse.Placeholder = "Response Text";
tbResponse.AddCssClass( "form-action-response" );
tbResponse.AddCssClass( "form-control" );
tbResponse.AddCssClass( "js-form-action-input" );
tbResponse.Text = nameValueResponse.Length > 3 ? nameValueResponse[3] : string.Empty;
_responseControls.Add( tbResponse );
}
}
示例7: CreateChildControls
/// <summary>
/// Creates the child controls.
/// </summary>
/// <returns></returns>
public override Control[] CreateChildControls( Type entityType, FilterField filterControl )
{
var controls = new List<Control>();
// Add the registration template picker
int? selectedTemplateId = null;
if ( _ddlRegistrationTemplate != null )
{
selectedTemplateId = _ddlRegistrationTemplate.SelectedValueAsId();
}
_ddlRegistrationTemplate = new RockDropDownList();
_ddlRegistrationTemplate.CssClass = "js-registration-template";
_ddlRegistrationTemplate.ID = filterControl.ID + "_ddlRegistrationTemplate";
_ddlRegistrationTemplate.Label = "Registration Template";
_ddlRegistrationTemplate.DataTextField = "Name";
_ddlRegistrationTemplate.DataValueField = "Id";
_ddlRegistrationTemplate.DataSource = new RegistrationTemplateService( new RockContext() ).Queryable()
.OrderBy( a => a.Name )
.Select( d => new
{
d.Id,
d.Name
} )
.ToList();
_ddlRegistrationTemplate.DataBind();
_ddlRegistrationTemplate.SelectedIndexChanged += ddlRegistrationTemplate_SelectedIndexChanged;
_ddlRegistrationTemplate.AutoPostBack = true;
_ddlRegistrationTemplate.SelectedValue = selectedTemplateId.ToStringSafe();
filterControl.Controls.Add( _ddlRegistrationTemplate );
// Now add the registration instance picker
_ddlRegistrationInstance = new RockDropDownList();
_ddlRegistrationInstance.CssClass = "js-registration-instance";
_ddlRegistrationInstance.Label = "Registration Instance";
_ddlRegistrationInstance.ID = filterControl.ID + "_ddlRegistrationInstance";
filterControl.Controls.Add( _ddlRegistrationInstance );
PopulateRegistrationInstanceList( _ddlRegistrationTemplate.SelectedValueAsId () ?? 0 );
_rblRegistrationType = new RockRadioButtonList();
_rblRegistrationType.CssClass = "js-registration-type";
_rblRegistrationType.ID = filterControl.ID + "_registrationType";
_rblRegistrationType.RepeatDirection = RepeatDirection.Horizontal;
_rblRegistrationType.Label = "Person";
_rblRegistrationType.Help = "Choose whether to filter by the person who did the registering (registrar) or the person who was registered (registrant).";
_rblRegistrationType.Items.Add( new ListItem( "Registrar", "1" ) );
_rblRegistrationType.Items.Add( new ListItem( "Registrant", "2" ) );
_rblRegistrationType.SelectedValue = "2";
filterControl.Controls.Add( _rblRegistrationType );
return new Control[3] { _ddlRegistrationTemplate, _ddlRegistrationInstance, _rblRegistrationType };
}
示例8: AddDynamicControls
/// <summary>
/// Adds the filter controls and grid columns for all of the registration template's form fields
/// that were configured to 'Show on Grid'
/// </summary>
private void AddDynamicControls()
{
phRegistrantFormFieldFilters.Controls.Clear();
phWaitListFormFieldFilters.Controls.Clear();
ClearGrid( gGroupPlacements );
ClearGrid( gRegistrants );
ClearGrid( gWaitList );
if ( RegistrantFields != null )
{
foreach ( var field in RegistrantFields )
{
if ( field.FieldSource == RegistrationFieldSource.PersonField && field.PersonFieldType.HasValue )
{
switch ( field.PersonFieldType.Value )
{
case RegistrationPersonFieldType.Campus:
{
var ddlCampus = new RockDropDownList();
ddlCampus.ID = "ddlCampus";
ddlCampus.Label = "Home Campus";
ddlCampus.DataValueField = "Id";
ddlCampus.DataTextField = "Name";
ddlCampus.DataSource = CampusCache.All();
ddlCampus.DataBind();
ddlCampus.Items.Insert( 0, new ListItem( "", "" ) );
ddlCampus.SetValue( fRegistrants.GetUserPreference( "Home Campus" ) );
phRegistrantFormFieldFilters.Controls.Add( ddlCampus );
var ddlCampus2 = new RockDropDownList();
ddlCampus2.ID = "ddlCampus";
ddlCampus2.Label = "Home Campus";
ddlCampus2.DataValueField = "Id";
ddlCampus2.DataTextField = "Name";
ddlCampus2.DataSource = CampusCache.All();
ddlCampus2.DataBind();
ddlCampus2.Items.Insert( 0, new ListItem( "", "" ) );
ddlCampus2.SetValue( fRegistrants.GetUserPreference( "WL-Home Campus" ) );
phWaitListFormFieldFilters.Controls.Add( ddlCampus2 );
var templateField = new RockLiteralField();
templateField.ID = "lCampus";
templateField.HeaderText = "Campus";
gRegistrants.Columns.Add( templateField );
var templateField2 = new RockLiteralField();
templateField2.ID = "lCampus";
templateField2.HeaderText = "Campus";
gGroupPlacements.Columns.Add( templateField2 );
var templateField3 = new RockLiteralField();
templateField3.ID = "lCampus";
templateField3.HeaderText = "Campus";
gWaitList.Columns.Add( templateField3 );
break;
}
case RegistrationPersonFieldType.Email:
{
var tbEmailFilter = new RockTextBox();
tbEmailFilter.ID = "tbEmailFilter";
tbEmailFilter.Label = "Email";
tbEmailFilter.Text = fRegistrants.GetUserPreference( "Email" );
phRegistrantFormFieldFilters.Controls.Add( tbEmailFilter );
var tbEmailFilter2 = new RockTextBox();
tbEmailFilter2.ID = "tbEmailFilter";
tbEmailFilter2.Label = "Email";
tbEmailFilter2.Text = fRegistrants.GetUserPreference( "WL-Email" );
phWaitListFormFieldFilters.Controls.Add( tbEmailFilter2 );
string dataFieldExpression = "PersonAlias.Person.Email";
var emailField = new RockBoundField();
emailField.DataField = dataFieldExpression;
emailField.HeaderText = "Email";
emailField.SortExpression = dataFieldExpression;
gRegistrants.Columns.Add( emailField );
var emailField2 = new RockBoundField();
emailField2.DataField = dataFieldExpression;
emailField2.HeaderText = "Email";
emailField2.SortExpression = dataFieldExpression;
gGroupPlacements.Columns.Add( emailField2 );
var emailField3 = new RockBoundField();
emailField3.DataField = dataFieldExpression;
emailField3.HeaderText = "Email";
emailField3.SortExpression = dataFieldExpression;
gWaitList.Columns.Add( emailField3 );
break;
}
case RegistrationPersonFieldType.Birthdate:
//.........这里部分代码省略.........