本文整理汇总了C#中Rock.Web.UI.Controls.RockDropDownList.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# RockDropDownList.SetValue方法的具体用法?C# RockDropDownList.SetValue怎么用?C# RockDropDownList.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Web.UI.Controls.RockDropDownList
的用法示例。
在下文中一共展示了RockDropDownList.SetValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateChildControls
/// <summary>
/// Creates the model representation of the child controls used to display and edit the filter settings.
/// Implement this version of CreateChildControls if your DataFilterComponent works the same in all filter modes
/// </summary>
/// <param name="entityType">The System Type of the entity to which the filter will be applied.</param>
/// <param name="filterControl">The control that serves as the container for the filter controls.</param>
/// <returns>
/// The array of new controls created to implement the filter.
/// </returns>
public override Control[] CreateChildControls( Type entityType, FilterField filterControl )
{
// Define Control: Group Data View Picker
var ddlDataView = new DataViewPicker();
ddlDataView.ID = filterControl.GetChildControlInstanceName( _CtlDataView );
ddlDataView.Label = "Is Member of Group from Data View";
ddlDataView.Help = "A Data View that filters the Groups included in the result. If no value is selected, any Groups that would be visible in a Group List will be included.";
filterControl.Controls.Add( ddlDataView );
// Define Control: Group Member Status DropDown List
var ddlGroupMemberStatus = new RockDropDownList();
ddlGroupMemberStatus.CssClass = "js-group-member-status";
ddlGroupMemberStatus.ID = filterControl.GetChildControlInstanceName( _CtlGroupStatus );
ddlGroupMemberStatus.Label = "with Group Member Status";
ddlGroupMemberStatus.Help = "Specifies the Status the Member must have to be included in the result. If no value is selected, Members of every Group Status will be shown.";
ddlGroupMemberStatus.BindToEnum<GroupMemberStatus>( true );
ddlGroupMemberStatus.SetValue( GroupMemberStatus.Active.ConvertToInt() );
filterControl.Controls.Add( ddlGroupMemberStatus );
// Define Control: Role Type DropDown List
var ddlRoleType = new RockDropDownList();
ddlRoleType.ID = filterControl.GetChildControlInstanceName( _CtlRoleType );
ddlRoleType.Label = "with Group Role Type";
ddlRoleType.Help = "Specifies the type of Group Role the Member must have to be included in the result. If no value is selected, Members in every Role will be shown.";
ddlRoleType.Items.Add( new ListItem( string.Empty, RoleTypeSpecifier.Any.ToString() ) );
ddlRoleType.Items.Add( new ListItem( "Leader", RoleTypeSpecifier.Leader.ToString() ) );
ddlRoleType.Items.Add( new ListItem( "Member", RoleTypeSpecifier.Member.ToString() ) );
filterControl.Controls.Add( ddlRoleType );
// Populate the Data View Picker
int entityTypeId = EntityTypeCache.Read( typeof( Model.Group ) ).Id;
ddlDataView.EntityTypeId = entityTypeId;
return new Control[] { ddlDataView, ddlGroupMemberStatus, ddlRoleType };
}
示例2: AddGridColumns
/// <summary>
/// Adds the grid columns.
/// </summary>
/// <param name="dataTable">The data table.</param>
private void AddGridColumns( Grid grid, DataTable dataTable )
{
bool showColumns = GetAttributeValue( "ShowColumns" ).AsBoolean();
var columnList = GetAttributeValue( "Columns" ).SplitDelimitedValues().ToList();
int rowsToEval = 10;
if ( dataTable.Rows.Count < 10 )
{
rowsToEval = dataTable.Rows.Count;
}
grid.Columns.Clear();
if ( !string.IsNullOrWhiteSpace( grid.PersonIdField ) )
{
grid.Columns.Add( new SelectField() );
}
GridFilterColumnLookup = new Dictionary<Control, string>();
foreach ( DataColumn dataTableColumn in dataTable.Columns )
{
if ( columnList.Count > 0 &&
( ( showColumns && !columnList.Contains( dataTableColumn.ColumnName, StringComparer.OrdinalIgnoreCase ) ) ||
( !showColumns && columnList.Contains( dataTableColumn.ColumnName, StringComparer.OrdinalIgnoreCase ) ) ) )
{
continue;
}
BoundField bf = new BoundField();
var splitCaseName = dataTableColumn.ColumnName.SplitCase();
if ( dataTableColumn.DataType == typeof( bool ) )
{
bf = new BoolField();
if ( GridFilter != null )
{
var id = "ddl" + dataTableColumn.ColumnName.RemoveSpecialCharacters();
var filterControl = new RockDropDownList()
{
Label = splitCaseName,
ID = id
};
GridFilterColumnLookup.Add( filterControl, dataTableColumn.ColumnName );
filterControl.Items.Add( BoolToString( null ) );
filterControl.Items.Add( BoolToString( true ) );
filterControl.Items.Add( BoolToString( false ) );
GridFilter.Controls.Add( filterControl );
var value = GridFilter.GetUserPreference( id );
if ( value != null )
{
filterControl.SetValue( value );
}
}
}
else if ( dataTableColumn.DataType == typeof( DateTime ) )
{
bf = new DateField();
for ( int i = 0; i < rowsToEval; i++ )
{
object dateObj = dataTable.Rows[i][dataTableColumn];
if ( dateObj is DateTime )
{
DateTime dateTime = ( DateTime ) dateObj;
if ( dateTime.TimeOfDay.Seconds != 0 )
{
bf = new DateTimeField();
break;
}
}
}
if ( GridFilter != null )
{
var id = "drp" + dataTableColumn.ColumnName.RemoveSpecialCharacters();
var filterControl = new DateRangePicker()
{
Label = splitCaseName,
ID = id,
};
GridFilterColumnLookup.Add( filterControl, dataTableColumn.ColumnName );
GridFilter.Controls.Add( filterControl );
var value = GridFilter.GetUserPreference( id );
if ( value != null )
//.........这里部分代码省略.........
示例3: CreateChildControls
/// <summary>
/// Creates the child controls.
/// </summary>
/// <returns></returns>
public override Control[] CreateChildControls( Type entityType, FilterField filterControl )
{
gp = new GroupPicker();
gp.ID = filterControl.ID + "_gp";
gp.Label = "Group(s)";
gp.SelectItem += gp_SelectItem;
gp.CssClass = "js-group-picker";
gp.AllowMultiSelect = true;
filterControl.Controls.Add( gp );
cbChildGroups = new RockCheckBox();
cbChildGroups.ID = filterControl.ID + "_cbChildsGroups";
cbChildGroups.Text = "Include Child Group(s)";
cbChildGroups.CssClass = "js-include-child-groups";
cbChildGroups.AutoPostBack = true;
cbChildGroups.CheckedChanged += gp_SelectItem;
filterControl.Controls.Add( cbChildGroups );
cbIncludeSelectedGroup = new RockCheckBox();
cbIncludeSelectedGroup.ID = filterControl.ID + "_cbIncludeSelectedGroup";
cbIncludeSelectedGroup.Text = "Include Selected Group(s)";
cbIncludeSelectedGroup.CssClass = "js-include-selected-groups";
cbIncludeSelectedGroup.AutoPostBack = true;
cbIncludeSelectedGroup.CheckedChanged += gp_SelectItem;
filterControl.Controls.Add( cbIncludeSelectedGroup );
cbChildGroupsPlusDescendants = new RockCheckBox();
cbChildGroupsPlusDescendants.ID = filterControl.ID + "_cbChildGroupsPlusDescendants";
cbChildGroupsPlusDescendants.Text = "Include All Descendants(s)";
cbChildGroupsPlusDescendants.CssClass = "js-include-child-groups-descendants";
cbChildGroupsPlusDescendants.AutoPostBack = true;
cbChildGroupsPlusDescendants.CheckedChanged += gp_SelectItem;
filterControl.Controls.Add( cbChildGroupsPlusDescendants );
cbIncludeInactiveGroups = new RockCheckBox();
cbIncludeInactiveGroups.ID = filterControl.ID + "_cbIncludeInactiveGroups";
cbIncludeInactiveGroups.Text = "Include Inactive Groups";
cbIncludeInactiveGroups.CssClass = "js-include-inactive-groups";
cbIncludeInactiveGroups.AutoPostBack = true;
cbIncludeInactiveGroups.CheckedChanged += gp_SelectItem;
filterControl.Controls.Add( cbIncludeInactiveGroups );
cblRole = new RockCheckBoxList();
cblRole.Label = "with Group Member Role(s) (optional)";
cblRole.ID = filterControl.ID + "_cblRole";
cblRole.CssClass = "js-roles";
cblRole.Visible = false;
filterControl.Controls.Add( cblRole );
RockDropDownList ddlGroupMemberStatus = new RockDropDownList();
ddlGroupMemberStatus.CssClass = "js-group-member-status";
ddlGroupMemberStatus.ID = filterControl.ID + "_ddlGroupMemberStatus";
ddlGroupMemberStatus.Label = "with Group Member Status";
ddlGroupMemberStatus.Help = "Select a specific group member status to only include group members with that status. Leaving this blank will return all members.";
ddlGroupMemberStatus.BindToEnum<GroupMemberStatus>( true );
ddlGroupMemberStatus.SetValue( GroupMemberStatus.Active.ConvertToInt() );
filterControl.Controls.Add( ddlGroupMemberStatus );
PanelWidget pwAdvanced = new PanelWidget();
filterControl.Controls.Add( pwAdvanced );
pwAdvanced.ID = filterControl.ID + "_pwAttributes";
pwAdvanced.Title = "Advanced Filters";
pwAdvanced.CssClass = "advanced-panel";
SlidingDateRangePicker addedOnDateRangePicker = new SlidingDateRangePicker();
addedOnDateRangePicker.ID = pwAdvanced.ID + "_addedOnDateRangePicker";
addedOnDateRangePicker.AddCssClass( "js-sliding-date-range" );
addedOnDateRangePicker.Label = "Date Added:";
addedOnDateRangePicker.Help = "Select the date range that the person was added to the group. Leaving this blank will not restrict results to a date range.";
pwAdvanced.Controls.Add( addedOnDateRangePicker );
return new Control[9] { gp, cbChildGroups, cbIncludeSelectedGroup, cbChildGroupsPlusDescendants, cblRole, ddlGroupMemberStatus, cbIncludeInactiveGroups, addedOnDateRangePicker, pwAdvanced };
}
示例4: CreateChildControls
/// <summary>
/// Creates the child controls.
/// </summary>
/// <param name="parentControl"></param>
/// <returns></returns>
public override System.Web.UI.Control[] CreateChildControls( System.Web.UI.Control parentControl )
{
RockRadioButtonList rblShowAsLinkType = new RockRadioButtonList();
rblShowAsLinkType.ID = parentControl.ID + "_rblShowAsLinkType";
rblShowAsLinkType.Items.Add( new ListItem( "Show Name Only", ShowAsLinkType.NameOnly.ConvertToInt().ToString() ) );
rblShowAsLinkType.Items.Add( new ListItem( "Show as Person Link", ShowAsLinkType.PersonLink.ConvertToInt().ToString() ) );
rblShowAsLinkType.Items.Add( new ListItem( "Show as Group Member Link", ShowAsLinkType.GroupMemberLink.ConvertToInt().ToString() ) );
parentControl.Controls.Add( rblShowAsLinkType );
int? selectedGroupTypeId = null;
if ( groupTypePicker != null )
{
selectedGroupTypeId = groupTypePicker.SelectedGroupTypeId;
}
groupTypePicker = new GroupTypePicker();
groupTypePicker.ID = parentControl.ID + "_groupTypePicker";
groupTypePicker.Label = "Group Type";
groupTypePicker.GroupTypes = new GroupTypeService( new RockContext() ).Queryable().OrderBy( a => a.Order ).ThenBy( a => a.Name ).ToList();
groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
groupTypePicker.AutoPostBack = true;
groupTypePicker.SelectedGroupTypeId = selectedGroupTypeId;
parentControl.Controls.Add( groupTypePicker );
cblRole = new RockCheckBoxList();
cblRole.Label = "with Group Role(s)";
cblRole.ID = parentControl.ID + "_cblRole";
parentControl.Controls.Add( cblRole );
PopulateGroupRolesCheckList( groupTypePicker.SelectedGroupTypeId ?? 0 );
RockDropDownList ddlGroupMemberStatus = new RockDropDownList();
ddlGroupMemberStatus.CssClass = "js-group-member-status";
ddlGroupMemberStatus.ID = parentControl.ID + "_ddlGroupMemberStatus";
ddlGroupMemberStatus.Label = "with Group Member Status";
ddlGroupMemberStatus.Help = "Select a specific group member status to only include group members with that status. Leaving this blank will return all members.";
ddlGroupMemberStatus.BindToEnum<GroupMemberStatus>( true );
ddlGroupMemberStatus.SetValue( GroupMemberStatus.Active.ConvertToInt() );
parentControl.Controls.Add( ddlGroupMemberStatus );
return new System.Web.UI.Control[] { rblShowAsLinkType, groupTypePicker, cblRole, ddlGroupMemberStatus };
}
示例5: 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:
//.........这里部分代码省略.........
示例6: CreateChildControls
/// <summary>
/// Creates the child controls.
/// </summary>
/// <param name="parentControl"></param>
/// <returns></returns>
public override Control[] CreateChildControls( Control parentControl )
{
// Define Control: Output Format DropDown List
var ddlFormat = new RockDropDownList();
ddlFormat.ID = parentControl.GetChildControlInstanceName( _CtlFormat );
ddlFormat.Label = "Output Format";
ddlFormat.Help = "Specifies the content and format of the values in this field.";
ddlFormat.Items.Add( new ListItem( "Group List: Name And Role", ListFormatSpecifier.GroupAndRole.ToString() ) );
ddlFormat.Items.Add( new ListItem( "Group List: Group Name", ListFormatSpecifier.GroupOnly.ToString() ) );
ddlFormat.Items.Add( new ListItem( "Yes/No: Yes if any participation", ListFormatSpecifier.YesNo.ToString() ) );
parentControl.Controls.Add( ddlFormat );
// Define Control: Group Data View Picker
var ddlDataView = new DataViewPicker();
ddlDataView.ID = parentControl.GetChildControlInstanceName( _CtlDataView );
ddlDataView.Label = "Participates in Groups";
ddlDataView.Help = "A Data View that filters the Groups included in the result. If no value is selected, any Groups that would be visible in a Group List will be included.";
parentControl.Controls.Add( ddlDataView );
// Define Control: Role Type DropDown List
var ddlRoleType = new RockDropDownList();
ddlRoleType.ID = parentControl.GetChildControlInstanceName( _CtlRoleType );
ddlRoleType.Label = "with Group Role Type";
ddlRoleType.Help = "Specifies the type of Group Role the Member must have to be included in the result. If no value is selected, Members in any Role will be included.";
ddlRoleType.Items.Add( new ListItem( string.Empty, RoleTypeSpecifier.Any.ToString() ) );
ddlRoleType.Items.Add( new ListItem( "Leader", RoleTypeSpecifier.Leader.ToString() ) );
ddlRoleType.Items.Add( new ListItem( "Member", RoleTypeSpecifier.Member.ToString() ) );
parentControl.Controls.Add( ddlRoleType );
// Define Control: Group Member Status DropDown List
var ddlGroupMemberStatus = new RockDropDownList();
ddlGroupMemberStatus.CssClass = "js-group-member-status";
ddlGroupMemberStatus.ID = parentControl.GetChildControlInstanceName( _CtlGroupStatus );
ddlGroupMemberStatus.Label = "with Group Member Status";
ddlGroupMemberStatus.Help = "Specifies the Status the Member must have to be included in the result. If no value is selected, Members of any Group Status will be shown.";
ddlGroupMemberStatus.BindToEnum<GroupMemberStatus>( true );
ddlGroupMemberStatus.SetValue( GroupMemberStatus.Active.ConvertToInt() );
parentControl.Controls.Add( ddlGroupMemberStatus );
// Populate the Data View Picker
int entityTypeId = EntityTypeCache.Read( typeof( Model.Group ) ).Id;
ddlDataView.EntityTypeId = entityTypeId;
return new Control[] { ddlDataView, ddlRoleType, ddlFormat, ddlGroupMemberStatus };
}
示例7: CreateChildControls
/// <summary>
/// Creates the child controls.
/// </summary>
/// <param name="parentControl"></param>
/// <returns></returns>
public override System.Web.UI.Control[] CreateChildControls( System.Web.UI.Control parentControl )
{
var groupTypePicker = new GroupTypePicker();
groupTypePicker.ID = parentControl.ID + "_groupTypePicker";
groupTypePicker.Label = "Group Type";
groupTypePicker.GroupTypes = new GroupTypeService( new RockContext() ).Queryable().OrderBy( a => a.Order ).ThenBy( a => a.Name ).ToList();
groupTypePicker.SelectedIndexChanged += groupTypePicker_SelectedIndexChanged;
groupTypePicker.AutoPostBack = true;
parentControl.Controls.Add( groupTypePicker );
int? selectedGroupTypeId = parentControl.Page.Request.Params[groupTypePicker.UniqueID].AsIntegerOrNull();
groupTypePicker.SelectedGroupTypeId = selectedGroupTypeId;
var cblRole = new RockCheckBoxList();
cblRole.Label = "with Group Role(s)";
cblRole.ID = parentControl.ID + "_cblRole";
parentControl.Controls.Add( cblRole );
PopulateGroupRolesCheckList( groupTypePicker.SelectedGroupTypeId ?? 0, cblRole );
RockDropDownList ddlGroupMemberStatus = new RockDropDownList();
ddlGroupMemberStatus.CssClass = "js-group-member-status";
ddlGroupMemberStatus.ID = parentControl.ID + "_ddlGroupMemberStatus";
ddlGroupMemberStatus.Label = "with Group Member Status";
ddlGroupMemberStatus.Help = "Select a specific group member status only include to only show true for group members with that status. Leaving this blank will return true for all members.";
ddlGroupMemberStatus.BindToEnum<GroupMemberStatus>( true );
ddlGroupMemberStatus.SetValue( GroupMemberStatus.Active.ConvertToInt() );
parentControl.Controls.Add( ddlGroupMemberStatus );
return new Control[3] { groupTypePicker, cblRole, ddlGroupMemberStatus };
}