1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Adding a Property that is a DropDownList

Adding a Property that is a DropDownList

7 posts, 0 answered
  1. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    11 Mar 2009
    Link to this post
    We've created some custom user controls that can have some extra properties we've defined.  But let's say I want to add a property that is not just a textbox (on the Properties tab when adding/editing the control to a page).

    Is this example:


    the best way to do that?  Or is there a way I can just make a drop down list appear on the Properties tab?
  2. mcpdinkansas
    mcpdinkansas avatar
    102 posts
    Registered:
    22 Mar 2007
    11 Mar 2009
    Link to this post
    I would also like to know the answer to this. I tried figuring this out on a custom control i built as well.
  3. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    16 Mar 2009
    Link to this post
    Hi,

    We have actually an example in SitefinityWatch.com - please take a look at the Using Enumerators to Auto-generate a Dropdown

    Let me know if you need any further assistance.

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  4. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    31 Mar 2009
    Link to this post

    Hi,

    Ok for Enum but how to add News Title is this dropdownlist, to build one designer to choose one SingleNews.

    Regards

  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    01 Apr 2009
    Link to this post
    Hello Pierre,

    Here is a sample that demonstrates using a Combo that is bounded to Generic Content Items Titles

    protected void Page_Load(object sender, EventArgs e) 
        {    
     
           // if it is a user control 
            if (!Page.IsPostBack) 
            { 
                NewsManager manager = new NewsManager("News"); 
                IList allNews = manager.Content.GetContent(); 
     
                this.Combo1.DataSource = allNews; 
                this.Combo1.DataBind(); 
            } 
     
        } 
     
         protected void RadComboBox1_ItemDataBound(object  o, RadComboBoxItemEventArgs e) 
         {    
             IContent content = e.Item.DataItem as IContent; 
             e.Item.Text = (string)content.GetMetaData("Title"); 
             e.Item.Value = content.ID.ToString(); 
         } 

    I hope this helps.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  6. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    01 Apr 2009
    Link to this post
    Hi Ivan,

    Thanks but I have same troubles that i haved with the dropdown, The RadComboBox Combo1 have in the items :"Telerik.Cms.Engine.Data.CmsContentBase" in place of RadComboBox1_ItemDataBound items with Title and ID. No other way to add the items of allNews.

    and
    this.Combo1.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventArgs("?");
    not fire the 
    protected void Combo1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) {}

    Many Thanks.
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    01 Apr 2009
    Link to this post
    Hello Pierre,

    The SelectedIndexChanged event does not fire unless the AutoPostBack property is True.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Register for webinar
7 posts, 0 answered