Groups > Web Hosting > Windows SharePoint Services > Re: Dropdownlist




Dropdownlist

Dropdownlist
Tue, 8 Aug 2006 12:15:11 +0000
I have created a webpart for SharePoint using asp.net 2.0. I have the code to
create a textbox in the edit zone and it work but I need it to be a
dropdownlist. Anyone know how?

using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace WebPartV3
{
    public class Pyr : WebPart
    {
        private string _Pyr;
        [
        WebBrowsable(true),
        Personalizable(PersonalizationScope.Shared),
        WebDisplayName("Pyr"),
        WebDescription("Chose your information"),
        ]

        public string GetSetPyr
        {
            set
            {
                _Pyr = value;
            }
            get
            {
                return _Pyr;
            }
        }

        protected override void CreateChildControls()
        {
            if (_Pyr == "" || _Pyr == null)
            {
                _Pyr = "blank.ascx";
            }
            Control Pyr = this.Page.LoadControl(@"/controls/" +
_Pyr);
            this.Controls.Add(Pyr);
        }
    }
}
Post Reply
Re: Dropdownlist
Thu, 10 Aug 2006 13:38:03 +000
Found a solution my self.

namespace PyrWebPartV3
{
    public class Pyra : WebPart
    {

        string _PyrUC;

        public enum enumSample
        {
            Pyr = 0,
            Pyr1 = 1,
            Pyr2 = 2,
        };

        private enumSample _Pyr;
        [
        WebBrowsable(true),
        Personalizable(PersonalizationScope.Shared),
        WebDisplayName("Pyr"),
        WebDescription("Choose your information"),
        ]

        public enumSample GetSetPyr
        {
            set
            {
                _Pyr = value;
            }
            get
            {
                return _Pyr;
            }
        }

        protected override void CreateChildControls()
        {
            if ((int)_Pyr == 0)
            {
                _PyrUC = "blank.ascx";
            }
            else if ((int)_Pyr == 1)
            {
                _Pyr = "pyr2_all.ascx";
            }
            else if ((int)_Pyr == 2)
            {
                _PyrUC = "pyr2_1.ascx";
            }
            else
            {
                _PyrUC = "blank.ascx";
            }

            Control Pyr = this.Page.LoadControl(@"/controls/" +
_PyrUC);
            this.Controls.Add(Pyr);
        }
    }
}
Post Reply
about | contact