コード例 #1
0
        /// <summary>
        /// Load content type and fields templates
        /// </summary>
        public override void DataBind()
        {
            foreach (SPContentType ct in this.Data.ContentTypes)
            {
                ContentTypeTemplate contentTypeTemplate = this.LoadControl("~/_layouts/SharepointDocGenerator/Templates/ContentTypeTemplate.ascx") as ContentTypeTemplate;
                contentTypeTemplate.Data = ct;
                contentTypeTemplate.DataBind();
                ContentTypeRepeater.Controls.Add(contentTypeTemplate);
            }

            List <SPField> fields = new List <SPField>();

            foreach (SPField field in this.Data.Fields)
            {
                fields.Add(field);
            }
            fieldsTemplate.Data = fields;
            fieldsTemplate.DataBind();
        }
コード例 #2
0
        /// <summary>
        /// Clicking the Ok button
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">EventArgs</param>
        protected void btnOk_Click(object sender, EventArgs e)
        {
            this.ControlsPanel.Visible = false;
            this.ResultsPanel.Visible  = true;
            // Get the selected fields
            List <SPField> selectedFields = new List <SPField>();

            foreach (int index in this.fields.GetSelectedIndices())
            {
                selectedFields.Add(this._fields.First(f => f.Id.ToString() == this.fields.Items[index].Value));
            }
            if (selectedFields.Count != 0)
            {
                FieldsTemplate fieldsTemplate = this.LoadControl("~/_layouts/SharepointDocGenerator/Templates/FieldsTemplate.ascx") as FieldsTemplate;
                fieldsTemplate.Data = selectedFields;
                fieldsTemplate.DataBind();
                this.PanelControls.Controls.Add(fieldsTemplate);
            }
            // Get the selected site content types
            foreach (int index in this.contentTypes.GetSelectedIndices())
            {
                ContentTypeTemplate contentTypeTemplate = this.LoadControl("~/_layouts/SharepointDocGenerator/Templates/ContentTypeTemplate.ascx") as ContentTypeTemplate;
                contentTypeTemplate.Data = this._contentTypes.First(ct => ct.Id.ToString() == this.contentTypes.Items[index].Value);
                contentTypeTemplate.DataBind();
                this.PanelControls.Controls.Add(contentTypeTemplate);
            }

            foreach (int index in this.lists.GetSelectedIndices())
            {
                ListTemplate listTemplate = this.LoadControl("~/_layouts/SharepointDocGenerator/Templates/ListTemplate.ascx") as ListTemplate;
                listTemplate.Data = this._lists.First(l => l.ID.ToString() == this.lists.Items[index].Value);
                listTemplate.DataBind();
                this.PanelControls.Controls.Add(listTemplate);
            }
            // Get the selected features
            List <SPFeature> selectedFeatures = new List <SPFeature>();

            foreach (int index in this.features.GetSelectedIndices())
            {
                selectedFeatures.Add(this._features.First(f => f.DefinitionId.ToString() == this.features.Items[index].Value));
            }
            if (selectedFeatures.Count != 0)
            {
                FeaturesTemplate featuresTemplate = this.LoadControl("~/_layouts/SharepointDocGenerator/Templates/FeaturesTemplate.ascx") as FeaturesTemplate;
                featuresTemplate.Data = selectedFeatures;
                featuresTemplate.DataBind();
                this.PanelControls.Controls.Add(featuresTemplate);
            }
            // Get the selected users
            List <SPUser> selectedUsers = new List <SPUser>();

            foreach (int index in this.users.GetSelectedIndices())
            {
                selectedUsers.Add(this._users.First(u => u.ID.ToString() == this.users.Items[index].Value));
            }
            if (selectedUsers.Count != 0)
            {
                UsersTemplate usersTemplate = this.LoadControl("~/_layouts/SharepointDocGenerator/Templates/UsersTemplate.ascx") as UsersTemplate;
                usersTemplate.Data = selectedUsers;
                usersTemplate.DataBind();
                this.PanelControls.Controls.Add(usersTemplate);
            }
        }